It's pure trig, the diffraction formula is not relevant here.
The same grating is used in both diagrams, just turned to a different angle to make the spacing look closer. You'd see the same thing if you looked at the safety fence near a pedestrian crossing from different angles as you rode your bike down the road past one.
In the second diagram is a right angle triangle hiding in plain sight. the hypotenuse is the real spacing of the grating d, the adjacent side is the apparent spacing da.