An erection is a physiological phenomenon during which the penis lengthens, becomes engorged, and firms. This phenomenon is often linked to sexual arousal, whereby the penis stiffens during sexual arousal or stimulation.
Having an erection, however, does not always occur as a result of sexual arousal. In some cases, they can be spontaneous or occur during sleep.