I recently found this animation which shows the motion of sun as observed from mercury. It seems as if the sun stops in between, retraces a bit and then continues towards the west. What is the reason for this strange motion? Is it because of variation in the distance between mercury and the sun? Or is it because a day on Mercury is longer than Mercury's year?
Both effects combined.
Day being longer than year would just have retrograde motion of the Sun on sky, but no direction change.
Variation of the distance alone happens on Earth, and we have no such effect.
But the combination of both factors, in the precise amount they have on Mercury, makes this effect happen.
Before about 1966, Mercury was thought to be tide-locked, almost half always sunlit and another near-half always dark – as most moons, including ours, are tide-locked to their primaries, and for the same reason. The difference in the strength of the primary's gravity between the inner and outer ‘poles’ creates a force tending to pull those points away from the center of the satellite, along the line joining it to the primary. If the satellite is ellipsoidal rather than spherical, the tide will tend to align the ellipsoid's long axis to the primary.
But Mercury's orbit is so eccentric that the strength of the solar tide varies by a ratio of 4:7 (if I've computed correctly). The rotation rate nearly matches the revolution rate at perihelion, when tide is strongest and Mercury is moving fastest; if the match were perfect (if the orbital eccentricity were a bit less), the sun's apparent path would have cusps rather than little loops. Presumably the imperfection is because the tidal effect does not vanish away from perihelion.
The loops have nothing to do with axial tilt; Envite was probably thinking of the analemma.