Both are used to cover the head of an individual.
Caps usually fit tightly around the head, and they don’t have a brim — a flat edge that goes all around a hat. A cap is usually made of soft material, and is equipped with a visor in the front.
Hats, on the other hand, are grander than caps. They vary in shape and are usually worn on formal occasions; caps are never worn to official functions such as state dinners. Both men and women have been wearing hats for a long time. In fact, a couple of centuries ago, a married woman had to wear a hat when she went out — this was to let people know that she was married. Single women, on the other hand, were allowed to go hatless.