Doctors used to tell you that smoking would help with lung problems, they used to give pregnant women medicine that would lead to birth defects claiming it would help the baby. Now they are saying that two glasses of wine a day could be healthy, and that masturbation is healthy.
Most doctors aren't scientists. There's also a lot of medicine that's not really based on science because there's either (1) not been enough time to systematic examine every scenario or (2) there's too many complex variables to be able to accurate study a situation so no real effort is made. That's not to say science hasn't severely misdirected medicine at times. There's also the point that most doctors weren't recommending people smoke. Instead, it was ads pointing out that (1) doctors did smoke "insert brand here" and (2) most doctors at the time didn't believe there was a link between smoking and lung cancer/illness. Given that it nominally takes 30+ years to see an effect and at the time near everyone smoked, it's not hard to see that without some clear, long-term science it'd be hard to verify that it was smoking that was the root cause. Even today a lot of people say things like "my grandpa smoked for 50 years and he's perfectly healthy".
Meanwhile, I don't see doctors today recommending people drink two glasses of wine a day (generally) or masturbate. At best, they're inclined to affirmatively enforce the notion that it's harmful/harmless and to what degree.
Science changes their opinion more than religion does, so if anything take it with a grain of salt.
Funny, I'd tend to think that's the good part about science. With a lot of religion, even when it's obvious that's something is harmful, dogma is still pushed. Science can lead to the wrong conclusions, will always be incomplete, can recommend very bad practices, etc. But it's also something that's willing that it makes mistakes and can grow beyond them. To that end, we've had a lot of people who think masturbation is harmful, sinful, etc, so it's not for a want of research that we haven't found clearly harmful effects.
I mean, we also haven't proven conclusively that combing your hair won't lead to concussions, but I'm not just going to jump into the "science has been wrong about stuff" to believe what whatever I want. If I want to believe something regardless of science (for, against, neutral, or no opinion), I'll just admit it and call it my religion.