Verbs don't change for gender. Only nouns and adjectives do. The -a ending on queda (inf. quedar) means that it applies to either him, her, it or you (formal), in this case being "it" (the hat). "Quedo" would mean "I stay/I fit"
I hope someone else will give their more experienced opinion but what I have found so far is that quedan isn't used on its own to mean 'fit'. What I did find is tht queda bien is idiomatic and means "to fit/to suit" and not necessarily includes 'well'.