An erection requires a healthy mind-body team effort led by the brain. First, the brain sends out signals. Then, the blood vessels, nerves, and hormones work together to create and keep an erection.
The soft penis
When a person assigned male at birth isn't aroused, then the brain, nerves, blood vessels, and hormones won't start working to cause an erection. The amount of blood flowing into the penis's spongy chambers (corpora cavernosa and corpus spongiosum) equals the amount flowing out. The penis stays soft.
The swollen penis
A person gets aroused by their senses. This includes sight and touch. And it includes thoughts, such as memories or fantasies. During arousal, messages brought by nerves cause the blood vessels and spongy chambers to open up (dilate). More blood flows into the penis than flows out. The penis starts to swell.
The erect penis
As arousal continues, nerves keep carrying messages between the penis and brain. Blood keeps moving into the man's penis. Blood-swollen tissues press against the veins. Some of the blood is kept from flowing back out. Filled with blood, the penis becomes hard. The person is able to have sex.