Although there can be various medical reasons for erectile dysfuntion like diabetes
,vascular diseases etc but at a such a young age the causes are generally psychological.Other non medical causes which can result in erectile dysfunction
( ED ) are...
Obesity,tobacco consumtion,lack of exercises,excessive work etc.
What to do..
Start doing regular aerobic exercises for at least 45 minutes a day.
Reduce your weight.
Do deep breathing exercises and yoga.
Talk with your wife and give proper time and foreplay with your wife.
You can even take the help of a psychiatrist
In couple of months time,you shall be all right.