I remember years ago at school we all had to have an examination at age 14/15....Not sure what happened to the girls but us boys had to stand in front of the woman doc/nurse not sure what she was, and lower our pants to below the knee. She put her fingers under the balls and you had to cough.
My friend got an erection and as he slid his pants down his cock bounced up and down in front of her...lol!
She turned to the desk and picked up what he called later a wooden spoon, gave the head of his cock a quick sharp tap , and told him to stand by the wall and cool off.
He said he couldn't get the hard on for at least a week!
I've sometimes got a brief erection myself during rectal exams when they feel the prostate, the last woman doc who did it was a very attractive aussie and very upfront about it, she said it oftens happens during that particular examination and not to worry about it. You're laying on your side facing away from them anyway so It doesn't really matter...