An erection happens when the corpora cavernosa expand and the penis becomes firm and elongated.