Thanks for the query.
I understand your concern.
As you are getting erection during masturbation possibly there may not be any structural or hormonal problem.
Anxiety and stress etc during intercourse can affect the sexual function, which may rectify soon.
If you repeatedly get the same problem, please do consult your doctor and get examined to find out the possible cause and take treatment accordingly.
These Q&A’s are for educational purposes and should not be relied upon as a substitute for medical advice you may receive from your physician. If you have a medical emergency, please call 911. These answers do not constitute or initiate a patient/doctor relationship.