Priapism. An erection lasting more than 4 hours is called priapism. Young men (teenagers) will frequently get erections at embarassing times. That is normal. As we age the spontaneous erections decrease as do nocturnal and morning erections. Male peak sexually at age 19 (sorry guys). After that its all "downhil". If your erections last for 4 hours your need to be evaluated (after you go to the er!).
Many reasons for. Prolonged erections. Most are benign and of little consequence. But be aware, if it's lasting for more than four hours or particularly painful or associated with color changes of the penis to white or blue then seek urgent help in a nearby ER.