This meaning of 'hat' refers to the different roles or jobs a person has. For example, a manager might also be a teacher.
He wears many hats at work.
In the meeting, she had a new hat.
In this context, 'hat' means the covering of a container like a bottle or jar. It keeps things inside safe.
Place the hat back on the jar.
Remove the hat from the box.
In technology, a 'hat' can refer to a software module that performs specific tasks. It is part of a larger system.
The hat controls the data input.
She added a new hat to the software.