Hats have many symbols for different occasions. For instance, we often think of a detective as a man with dark shades and a hat to hide his identity.
Similarly, to dream of a hat refers to hiding something.
To dream of hats reflects different roles you play in life. Wearing a top hat in a dream refers to wealth, elegance and formality.