A good example of how important it is to learn mating patterns.
The key move is simple to spot if you know the dovetail mating pattern, because from h7 the queen is threatening Qe4#. And that leads you to solving the second move, because b4 cuts off the escape square just made by black's previous c4 move. And so on. The problem almost solves itself if you've got that starting knowledge.
In a game I would probablyt have chosen the correct first move simply because it looked like a doog aggressive threat, without necessarily having thought out the variations. It threatens immediate mate, and while it doesn't cover any of Black's three flight squares, the Q is clearly setting itself up so that moving Black's king to any of those squares brings it closer to danger.