“Just a guess, but I bet very few of the students wearing hats indoors are doing so for religious reasons”
It’s not that they are wearing them for religious reasons. It’s that the idea that there is something rude about wearing a hat indoors is based on a culture that is not shared by all. If your religious culture is that (indoor or outdoor) hats are a sign of respect, even if you don’t observe that part of the religion the idea that wearing one is rude would be foreign.
Basically the school says "wear what you want as long as it’s not offensive, but be ready to be a lesson in what not to wear
The school also tells staff that this " lesson" must be respectful and not made in public.