Someone in a neighboring school to mine did it in both Health class and French class, because the people pictured in the textbooks were attractive. The teacher for the health class one was very, very gung-ho about other peoples' health (like he'd order you to go to the cafeteria to eat if you skipped lunch, that kind of thing), and after that, it became a running joke to ask him (the health teacher) if they could "improve their lower health".
Back when I was in high school, it wasn't uncommon for teachers to use the same restrooms as the students. I can't quite remember but I think there were only a couple staff toilets on the campus, one in each gendered locker room and one in the front office.
Anyway, my point is there's at least the possibility that the principal was just using the bathroom normally and the poor kid was being... less than subtle about what he was doing in the stall.
Bathrooms were shared back then between teachers and students. And when this happened, it was while class was ongoing, so he had very little expectation that he would run into any kids outside of class.