The penis is composed of three cylinders encased in a sheath called the bucks fascia. These three cylinders are the corpus spongiosum and two corpora cavernosa known as the corpus cavernosum of penis.
The corpus cavernosum contains spongy erectile tissue. Cavernosal arteries run along the middle of each corpus cavernosa. The function of the corpus cavernosum is to facilitate penile erections.
Muscles surround the cavernosum and spongiosum. These muscles support the penis when erect and contract during ejaculation.
To achieve erection the brain sends impulses to the nerves in the penis and these cause the multiple muscles around the corpus cavernosum penis to relax. This allows blood to flow in to the open spaces inside the corpora cavernosa. This blood creates pressure making the penis expand, which then compresses the veins that normally allow blood to drain. Once the blood is trapped, a muscle located in the corpora cavernosa helps to sustain the erection.
An erection is reversed once the muscles in the penis contract preventing blood flow in to the corpora cavernosa.