Hat Trick

What does the idiom “hat trick” mean?

Definition: Scoring three goals in hockey or soccer (football), or accomplishing three of anything.

Example: The striker scored a hat trick in the first five minutes, and after that the match was never close.