Using illegal drugs is illegal.
Yet Obama and Steve Jobs confess that freely. Write a book about it.
Imagine if they confess to murder instead. That would be problematic.
So why?
Law Stack Exchange is a question and answer site for legal professionals, students, and others with experience or interest in law. It only takes a minute to sign up.
Sign up to join this communityNot all illegal things are crimes.
Lack of evidence. They are asked to testify, and they say "what I said in my book was a lie". There is no general law against lying, except when under oath.
Statute of limitations. Saying "10 years ago I did smoke drugs" means that any offence is no longer prosecutable.
Lack of details. Which jurisdiction were they in? When did they commit the act, how many acts? You cannot be arrested for being a "bank robber" or a "murderer". You are charged with "robbing Bank X on 123 Fake Street the Thursday 25 April 2018" or "murdering Jim Thio in January 2017". Otherwise the defendant would have a hard time defending himself (how to prove that you have not killed anyone at any time?)
All of the above combined with prosecutorial discretion in the form that any possible prosecutor will most likely determine that bringing charges would be just a waste of time and resources.
UPDATE February 2018: Just for the sake of completeness, a reference to the situation of Jacques Cassandri, who did boast about a serious crime(a robbery in a Societe Generale vault in 1976) in a book.
Unfortunately for him, he made some kind of mistake/miscalculation and the crime had not yet expired, so he has become an example of someone being prosecuted by confessing a crime in a book.