Before this move, White's Bb5 was just attacking Black's Nc6. After 4...d6, it's Black himself who turns the plain attack into an Absolute Pin, sticking the Nc6 against its King.

4...a6 has a better chance of pushing back White's light-Bishop, followed by 5...b5, developing another Pawn, (making White move the Bishop AGAIN, if it only retreats to either a4 or c4), while also putting an extra Pawn on the h4-e8 diagonal, reducing the pressure on the King along this line.

That then frees up Nc6, breaking the Pin, and enables 4...d6, to support the e5-Pawn.

So, 4...d6 appears to have been played a couple of moves too early.

5...Nxe4, Seems harmless, as it "wins a free pawn".

But, Black has actually obliged White's Clearance Sacrifice - the e4-Pawn was in the way of White's KR taking its role in the Discovered Check which Checkmates Black's King (12. Bb5#).

10...exf3, Black possibly got over excited with his Pawn Fork against White's Knight and light-Bishop that he can't have properly assessed the re-positioning of White's light-Bishop, in front of Re1 ...

Black has left a clear path all the way to his King, ready for the aforementioned Discovered Check.

In hindsight, Black's Pawn should have stayed put on e4, possibly advancing his b-Pawn to b5, which prevents Black's final headache: White's own Pawn Fork against Black's Ra1 & Bc8!.

Checkmate Sequence + PGN

Here's how the Ruy Lopez can lead to a Checkmate Win for White, in the Opening phase: