How does erection occur and why?
Erection is a complex mechanism of nervous and vascular interactions usually starting in the brain and is connected to sexual stimulation.
During sexual arousal signals from the brain travel to the lower spinal cord and further to local nerves, causing the smooth muscles in the arterial walls to relax. As a consequence the inflow of blood is increased and the spongy tissue in the corpora cavernosa fills with blood. The filled-up corpora cavernosa mechanically compress the emissary veins, which results in reduced outflow of blood. The penis fills with blood, elongates and becomes rigid.
Cross-section of the penis

During erection blood is "trapped" in the penis.
Erection ends after ejaculation or when erection-causing signals cease due to external influences. The inflow of blood as well as the pressure of the corpora cavernosa on the emissary veins is reduced. This causes blood to leave the corpora cavernosa and the penis returns to its flaccid state.
There is six times more blood in the penis during erection as in the flaccid state.
