Initially this does not create an erection but an electrical impulse is transmitted to the tiny cowpers glands, located along the sides of the urethra. These glands produce a few drops of the clear slippery fluid that forms at the tip of the penis. The function of this fluid is to act as a lubricant for sexual intercourse. The reason pornography sells well and strip dancers are so enjoyed by men is because it often elicits this response of physiological well-being. In gay men, the arousal mechanism works the same, but the object of sexual attraction is another man.
Erection occurs after a period or arousal.
In young men it may be often very soon after initial arousal and without any need for manual stimulation of the penis. As men age, arousal can continue indefinitely without erection which may need additional manual help. Erection occurs when the spongy tissues of the penis are engorged with blood. There is one large primary artery bringing blood into the penis, and several smaller veins that drain blood out of the penis. When not sexually stimulated there is a balance of blood flow in and out and the penis is flaccid.