There are little muscles at the base attached to the pelvic area but the transformation you might have noticed is due to the internal tissue being like a sponge, that becomes filled with blood. The circulation proceeds normally for most of the time but for its amazing peformance the exit for the blood is cut off and it fills up, becoming rigid. This is so that it can perform its next task of exploring the universe in search of some place to pop its head.