An erection requires a healthy mind-body "team effort" led by the brain. Upon receiving signals from the brain, the blood vessels, nerves, and hormones work together to cause and maintain an erection.
If nothing is causing a man to become aroused, then his body's erection "team" of brain, nerves, blood vessels, and hormones won't begin 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. His penis remains soft.
A man becomes aroused through his senses (such as sight or touch) or his thoughts (such as memories or fantasies). During arousal, messages brought by nerves cause the blood vessels and spongy chambers to dilate (open up). More blood flows into his penis than flows out. His penis starts to swell.
As arousal continues, nerves keep carrying messages of arousal 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, his penis becomes rigid. The man is able to have intercourse.