The language is peppered and salted with sporting terms. Whether somebody is fielding questions, playing on a sticky wicket or hitting something for six, he is playing cricket.
Slightly more obscure is the feat of H.H. Stephenson in 1858. Stephenson was a fast bowler who took 303 wickets over the course of his career. He once took three wickets with consecutive balls. Nobody had done this before. Everybody was terribly impressed with Stephenson: he had taken a trick of three wickets (trick as in card games). They felt Stephenson should have an award, but they didn't know what to award him. So they made him a special hat.
That's why it's a hat trick.
Incidentally, a google was originally a kind of cricket delivery, a forerunner of the googly.
P.S. I was at the cricket yesterday and it has been scandalously unreported in the papers that when Amir was facing his first delivery somebody with a very loud voice shouted "No ball".
P.P.S. I can't work out exactly what a google was. Anybody know?