It's a shame that this phenomenon is most prevalent in our youth, when we are too self conscious about it to deal with it comfortably. Now that I'm a senior citizen those spontaneous, unexpected erections are relatively rare, but when they do happen it doesn't bother me at all. In my youth, however, it was a different story.
Prior to my getting a driver's license I relied quite heavily on the city's transit system to get around town and every time I rode one of those damned buses the vibrations from the road and the bus' GMC 6-71 two-stroke diesel engine would cause me to pop a boner. If the trip was long enough, like clear across town, I would sometimes mostly lose the erection before I had to rise from my seat and get off the bus. But most of the time I'd still be rock hard and embarrassed when it came time to disembark. I finally learned that if I stood instead of taking a seat, and just hung on to the overhead grab bar or one of the vertical risers, that my erection would just create a VPL in my jeans instead of the obvious tent I would get when seated. But standing just seemed to draw attention to me, so either way it was pretty damned embarrassing.
Even more embarrassing were the occasional boners I'd get in class at high school. I have no idea why but that seemed to happen most often in my orchestra class. To make matters worse, the older student who sat next to me in orchestra would invariably notice my boner and would giggle and draw others' attention to my plight. As much as I enjoyed playing in the ensemble, after one year I quit taking orchestra simply because it was giving me those embarrassing erections. Go figure.