Erectile dysfunction can develop in young adults due to a variety of causes. Psychological stress, performance anxiety, depression, neurogenic disorders peyronie's disease, body image issues, medications, alcohol, smoking, drugs/medications, hormonal imbalance, radiation therapy, kidney failure, metabolic disorders, multiple sclerosis, hypertension, diabetes, prostatitis, urethritis etc. just to name a few. None of the medical conditions is the past history is likely to be responsible for the condition in your case. Anxiety and stress play an important role in adolescents in the development of erectile dysfunction; and is the most common possible cause. At a primary level, I would suggest being a bit relaxed and working on the psychological factors. You could also see a psychotherapist/ behavioral therapist for the same. It might also be beneficial to get rid of factors like smoking/ alcohol/ drugs, if involved. In case this doesn’t work, or you have difficulty controlling anxiety; I would suggest seeing your primary care physician for an evaluation of the above mentioned causes and appropriate specific treatment.
Hope this helps.