You can't. It is natural and individual, you can only manage it by wearing absorbent underwear (like cotton). Getting spontaneous erections usually mostly goes away with age so hopefully won't be as bothersome in a few years.
Think about something different
a "reduction" of blood flow may prevent him getting an erection
You can't completely prevent yourself from tasting, but holding you nose can keep you from tasting some things.
To prevent jelousy you can make yourself as good as the person your jelous of.
You can prevent getting these sicknesses by not exposing yourself to the rain and also by taking daily vitamins.
There are a number of medications that have a side-effect of impotence, the inability to have an erection.
nothing
Isolation
By not doing it .)
Yeas this is true case when you sleep you get every 30 min a erection this is so the blood go through the penis to keep it going and also prevent that you pee in the bed.
I say you should get caulking and cover any hole also spray worm repelent
by taking care of yourself