A few things; one, even if it's not strictly speaking true that cocaine use always leads to addiction every single time, we know now better than in Victorian era England how often it does, and Doyle not having been a cocaine user may have lost some of the elements of how cocaine is addictive and what it looks like. I hate to say that there is some moral duty to show a protagonist using cocaine as having a problem with its use that needs to be overcome, but I do think it'd be strange too to keep what was effectively this SMBC comic (https://smbc-comics.com/index.php?db=comics&id=191) as Holmes' use of coke.

Secondly, the stories that mention coke use are all written from the perspective of Holmes' best friend, who we'd expect to be biased towards writing about his friend in a positive light. I don't think this is accidental. Watson quotes him effectively saying "I just do coke because life is so mundane and boring, and not stimulating enough for me" which is nearly the exact same justification and thought process used by like, every addict and if not a word-for-word quote, then at least very similar for Chris Moltisanti's justification of his own addiction to Tony Soprano.

It may not be an exact rendering of what was in the books but it is extremely natural modification to make, where otherwise we'd have flat Marty Stu character who is talking in ways that seem very consistent with at least problematic use and yet who's not addicted. "Our own times" have dealt with at least 100 years of coke addiction, 50 years of crack so maybe we're just not naive enough to believe that a guy who's saying "my friend just takes it when he's bored, but he's bored all the time because his mind is too sharp for this dull world" isn't a problematic user or addict.