Suppose you did this to a black coworker and he struck back by filing one of the many harassment options available. Or, suppose you did it to everybody except the black (or woman or lesbian or gay) and they complain because you haven’t treated them the same. The world has changed and things that were once viewed as harmless are now viewed through a different lens.
Making somebody feel like an idiot is never a good idea.
Our joker once complained that nobody took him seriously. I rattled off the most recent six or seven times he’d fooled somebody and he wailed, “but this time I’m serious.” He could have claimed the building was on fire and because he’d said it no amount of smoke would have convinced us.
Is our military better as a result?
That is why no sane person would work in an environment like in your examples. As that environment started to form in the workforce I removed myself from any job that held those traps. It limited my choices, but it has made my life much easier.
I grew up around the Navy, bases and hangars and knew all the pranks before I ever joined. I never participated in the games once in the service, but understand their utility.