When stimulated by the nerves, the spongy tissue arranges itself in such a way that more blood can be stored in the penis. The veins running through the outer sheath of the penis then compress which stops the blood from leaving the penis. As the blood is stopped from flowing out, the penis fills with blood and stretches within the outer casing, giving an erection.
A common and important cause of ED is vasculogenic. Many men with ED have comorbid conditions such as hyperlipidemia, hypercholesterolemia, tobacco abuse, diabetes mellitus, or coronary artery disease (CAD).  The Princeton III Consensus recommends screening men who present with ED for cardiovascular risk factors; ED may be the earliest presentation of atherosclerosis and vascular disease. 
One study by Palmer and colleagues evaluated sildenafil use in SB males with thoracic lesions (76). A prospective, blinded, randomized, placebo-controlled, dose-escalation, crossover study in 17 patients with SB and ED was performed. All study participates took sets of tablet in groups, two sets of placebo, one of 25 mg, and the last 50 mg. Overall response to the tablet sets was measured by IIEF response and self-report of erectile rigidity. Patients reported that taking 50 mg of sildenafil led to improved erections, duration of erections, frequency of erections and level of confidence compared to sildenafil 25 mg and more significantly compared to placebo. Of the five patients who reported side effects, two experienced mild hematological changes that reverted to baseline after study completion.
Take an ED drug. Such drugs can help men maintain erections for several hours at a time. They work by enhancing the effect of nitric oxide, which the body produces naturally to relax and increase blood flow to the penis. If you're interested in taking a drug specifically geared toward treating ED, talk with your doctor about getting a prescription.
ED can also occur among younger men. A 2013 study found that one in four men seeking their first treatment for ED were under the age of 40. The researchers found a stronger correlation between smoking and illicit drug use and ED in men under 40 than among older men. That suggests that lifestyle choices may be a main contributing factor for ED in younger men.
A physical exam checks your total health. Examination focusing on your genitals (penis and testicles) is often done to check for ED. Based on your age and risk factors, the exam may also focus on your heart and blood system: heart, peripheral pulses and blood pressure. Based on your age and family history your doctor may do a rectal exam to check the prostate. These tests are not painful. Most patients do not need a lot of testing before starting treatment.