Guys hit puberty, and one day you're 12 or 13, and you've been looking at the girl sitting in front of you at school, and you've got a boner, and then you realize the teacher is calling your name. You suddenly realize that you've got to learn to keep these boners under control!
And by the time you hit 16 or so, you've mostly figured out how to do that, which is to keep your bodily reactions under tight control (these also include the urge to grab and squeeze every nice ass or boob that is in your vicinity, among others). When you're first learning to do that, it isn't easy, and you have to think about it a lot, but eventually it becomes automatic, and guys spend the rest of their lives actively controlling themselves whenever they're in mixed company. We often forget we're even doing it, because it kind of happens in the background.
We can and do let go of that control when we're in a "safe" environment, like being at home alone, or in our office at work, or any other place where a boner isn't going to be an issue. We also purposely let go of that control when we're on a date, because boners are expected, even hoped for, in that setting.
So for the most part, surprise boners are unusual, but every once in a while, you may have relaxed your control a bit, thinking that things are "safe", and then suddenly you see or hear something that's VERY sexy or sexual that you weren't expecting, and BAM! Now you've got a tent happening that wasn't part of your plans. For most guys, these unwanted stiffies only happen when they get caught unawares, but yeah, some guys do have a problem where they can get one even when they're actively trying to control it.
If you're dressing sexy, exposing some cleavage or have some tight pants on or a skirt showing leg or whatever it is he really likes, then, yes, it's possible.