Two moves kill it: get a knight to c6, then put a pawn on g6. After that the four-move mate does not exist and the player who tried it has a queen in the middle of the board with nowhere useful to go.
8
7
2
a
b
c
d
e
f
g
h 1
8
7
2
a
b
c
e
g
h 1 Why each move does its job
2…Nc6 defends the pawn on e5. Do not skip it. If you answer 2.Qh5 with 2…g6 straight away, 3.Qxe5+ forks your king and the rook on h8, and you have lost a rook in three moves while defending against a mate that had not happened yet.
3…g6 attacks the queen on h5 and sends her somewhere else, and it means that if she ever lands on f7 your king is no longer the only thing defending the square. White has to move the queen again.
4…Nf6 is the move people miss. White’s queen on f3 is aiming at f7 down the f-file, with the bishop on c4 backing her up, and that really is mate if you let it happen. The knight on f6 stands in the way. It also develops, which is the point: you are defending with pieces that you wanted to move anyway.
The other defence: 3…Qe7
If you prefer not to touch the kingside pawns, meet 3.Bc4 with 3…Qe7. The queen defends f7 herself, and White’s queen has run out of ways in. It looks clumsy and it is completely sound; the queen drops back to d8 or c7 later once you have played …d6 and …Nf6.
I teach 3…g6 to children and 3…Qe7 to adults who hate loosening pawns. Both work.
Now make her pay
This is the half that beginners forget. Defending is not the goal; the free moves are.
From the second board, 5.g4 lets Black play 5…Nd4, hitting the queen on f3 and the pawn on c2 at the same time. Whichever way White answers, Black has developed three pieces and White has developed one and moved the queen three times. Play …Bg7, castle, then break with …d5 and the position plays itself.
One warning. The mate is only dead if you keep watching f7: leave it hanging while you do something clever and you will get mated after all. And once you have met the queen raid twice you will start seeing the same idea in reverse, which is what the f7 puzzles are for.