Thank you for asking. I can understand your concern. Stress, anxiety are very common causes of Erectile dysfunctions. Performance anxiety is also a common problem. Worries and thoughts about not able to perform especially just before sex or during it often triggers anxiety attack which can hinder with normal erections. One must also consider and explore masturbation habits and use of pornography, they often lead to Erection problems.
Next Steps
I would suggest you to consult with a sexologist for further management and detailed instructions. With suitable medications and instructions it can be completely cured.
Health Tips
Don't worry. It is treatable.