Hats are a reminiscent of helmets worn by knights and soldiers to protect their heads.
We no longer need helmets at work, therefore the more strict the enforcement to wear hats off effective duty, the the more managements admit bombarding us with unneccessary crap, just proving their incompetence.