Caption: Mercury's orbit exhibits a 3:2 spin-orbit resonance which is illustrated in the diagram.
Features:
Say you land on Mercury on the equator just at noon on top of a giant mountain.
Now 3/2 axial rotation periods later, 1 Mercurian year has passed (i.e., Mercurian orbital rotation period P_O = 87.9691 days = 0.240846 yr = (3/2)*P_A = (1/2)*P_D has passed).
But since it is 3/2 axial rotation periods, it is now midnight for you.
It takes another 3/2 axial rotation periods to bring you back to noon.
Thus the Mercurian synodic day P_D = 175.942 days = 2*P_O = 3*P_A (i.e., noon to noon) is 3 axial rotation periods = 2 orbital periods (i.e., 2 Mercurian years).
Subtle stabilizing effects damp out any changes in the ratios set by the 3:2 spin-orbit resonance caused by astronomical perturbations.
In the case of Mercury's orbit, the oscillations are axial rotations and orbit rotations.
From the specialized formulae for the synodic period (see Orbit file: synodic_period.html), we have, in fact, Mercurian day equal to 2 orbital periods = 175.9382 days. The diagram also shows why this must be so (as aforesaid).
The accurate Mercurian day = 175.942 days (NASA: Mercury fact sheet, 2021). The discrepancy between our calculated value and NASA's may be due to the specialized formulae being based on assumption that Mercury having a circular orbit which is NOT the case. There might be other reasons for the slight discrepancy: e.g., astronomical perturbations and/or observational error.