The physical act of holding your penis to urinate provides tactile stimulation, which, when combined with the subconscious association of the pelvic region with arousal, can result in an involuntary erection. Have you ever masturbated at a public urinal?