I can understand your concern. It could be a problem of Erectile dysfunction. Apart from too frequent masturbation and smoking, a very important risk factors for Erectile Dysfunction in your age group is pornography use. Use of pornography esp. while masturbation, is a major factor. Stress, anxiety also contributes in erection problems. A detailed information regarding all these issues is needed. They need to be specifically managed.
Next Steps
Kindly consult with a sexologist for further management. For more information you can ask a detailed query here on practo.
Health Tips
It can be treated.