Hats hide your face. People can't "read" you and your emotions if they can see your face. Also there have been groups or gangs that identify each other by hats. School is suppose treat everyone equally, and by marking affiliations it creates divisiveness.
I think the reason as to why hats are not worn in school is because they hide one's identity. A school is a place where minds are taken to blossom, and if fashion gets in between then the whole meaning of a school would change.
Here's an answer, let me know what you think. If you trace the reasoning way back in time you will see by wearing your crown (a hat) you put yourself on equal footing with the King (the authority in question). By having you remove your crown in the King's presence you make yourself subservient to his authority while in his presence.