Why is this the solution?

The solution is: f5+, g6xf5+, g4xf5+,kf7, kd5, kg7, nxf6,kxf6

But why should white play kd5 out of all the moves ge could play?? It seems Like a random solution for me. Like "yeah this is the best strategy but only if white does exactly whats in your favor"

The solution is: f5+, g6xf5+, g4xf5+,kf7, kd5, kg7, nxf6,kxf6

But why should white play kd5 out of all the moves ge could play?? It seems Like a random solution for me. Like "yeah this is the best strategy but only if white does exactly whats in your favor"