It's not doctors, but nueroscientists understand how these things work better. How what stimulous affects the mind, the memories and thus the feelings and hormones.
Real life sex is something different. There are tests with digital EEG probes hooked up to the mind which show the difference. There are certain regions of the brain which are stimulated, memories and "acknowledgements" in the human mind which are filled and triggered by real life sex vs jagging off to a porn image.
Many of the guys here who "pay attention" and even dating coach AMS had noted, that in a sexual "drought" one of the worst things you can do is masturbate. However, with The procurement of real sex with a lady who desires you has this side effect of feeding your "sexual image", and you will move and have a swagger of a "desired man", your pheremones will raise, and so will your confident. jagging off to porn can't do that, it actually degrades your sexual self image. It feeds feelings of inadequacy and is teaches you failure.
A man that gets enough sex on demand is viewed as "arrogant" by the world, because he moves with a sense of entitlement, and all of his energies are tuned on that wavelength of being an sexual attractant.
BTW, "doctors" aren't always "right". They know their larea and what schooling has told them. For many years body builders and high performance atheletes where way ahead of the "docs" on what's possible how how to achieve cutting edge results in the body composition and atheletic performance.
Actual sex affects hormone levels in the human body:
https://www.medicalnewstoday.com/articles/321428
And you thought you just weren't doing it right
www.theregister.com