Hi there...I can understand your concern. But first and foremost you must understand that masturbation in way helps improve your height. Also masturbating once in a while is a healthy habit. But overdoing anything is always bad. Try to occupy yourself with other things like hanging out with friends, involving yourself in good habits, activities.
Erectile dysfunction could be due to many reasons. Anxiety being the most. So first try relaxation techniques and distraction method. Then try to cut down on any habits like alcohol, smoking or drugs. If there's no improvement then you must be investigated for any comorbidities like
diabetes hypertension hypercholestrolemia. Treating these comorbidities also can improve erection. Medically there are many options like oral medications and topical creams. If the above conservative measure do not help kindly consult a psychiatrist for medical therapy.