The school where I did the equivalent of elementary/middle school education had a strict "absolutely no hats" rule.
I have no clue why, but if you were caught wearing a hat (or cap or...) you'd get into trouble. First time a warning and you take it off. Second time they take the hat away from you and return it after seven days. Third time you get suspended.
My high school had a "no hats indoors" rule and even that was regarded as dumb. No hats at all? Screw you if you wanna keep the sun out of your eyes I guess?