Yeah this is more common than most guys suspect.
The technical term is something along the lines of your sphynktas locking up. I can't remember exactly but I'm sure someone will know.
We just refer to it as 'Stage Fright'
It's definitely happened to me a few times
Worst was in high school when a teacher decided he needed to have a pee at the same time as me. Still to this day don't know if he noticed