Original: In some males, erection can occur spontaneously at any time of day, and is known as nocturnal penile tumescence when occurring during rapid eye movement sleep.
Simplified: The scientific term for this is nocturnal penile tumescence (which means "swelling of the penis at night"). It is also common for a man to wake up after a night's sleep to find that he has an erection.