A ligament along the top of the penis is attached to the pubic bone.
The developmental length of this ligament is what defines the angle of the erection, and even the curvature of the erection.
As you grow up... if you wear tighty whities all the time, with your dick laying upward against your stomach... you may end up with a ligament that is shorter and tighter, causing a more upward and or pronounced upward curve. ( just like your hamstrings... ligaments are more readily stretched in youth )
If you let it hang down your trouser leg, the tendon will, over time, become more relaxed resulting in a straighter or even more downward pointing erection.
Some folks, most notably Fakir Musafar, have had this tendon cut, as, if very tight, it will make the penis somewhat longer... however... this is not a good idea, because it severs the connection to the pubic bone that allows the stiffened penis to be backed by the pubic bone, and can allow the penis to shift in ways that make penetrative sex very uncomfortable, or awkward. It also makes your erection point straight downward...