Glasses are devices used to help vision, and are worn on the face. The face is part of the head. Glasses are therefore worn on the head, as are hats. Technically, glasses can be classified as both an accessory and a hat. Scarfs are worn around the neck, a bandana is worn on the head (so technically a hat) and ear-rings are jewelry, so they are an accessory.

"Head covering of any of various styles, used for warmth, fashion, or religious or ceremonial purposes,..." That's another definition of hat. Glasses can be used for fashion and for legitimate health correction. It's both an accessory and it's a hat.