Why does the penis shrink when you are scared or frightened?

Protection. It's hiding as a protective mechanism. If attacked, you need your brain, heart, lungs, eyes, arms and legs to help you win the battle -- not your penis.