An erection occurs when your imagination or one or more of the senses
(vision, hearing, touch, smell, taste) are stimulated and you become aroused.
Your central nervous system sends nerve impulses that increase blood flow to
your penis. The blood fills the spongy chambers (corpora cavernosa) in the
penis, causing them to expand and become rigid. The veins that would normally
drain blood from the penis are constricted, trapping the blood inside and
maintaining the erection.
An erection goes down because the arteries narrow, the veins expand,
and the blood drains out of the penis. The penis returns to its normal size and
is no longer rigid.