Retrogradation movement of planet Mars relatively from Earth by Copernic
You are right.  If Mars orbited in exactly the same plane as the Earth, instead of an S or a loop, we would see Mars moving prograde relative for the stars along the ecliptic, then slowing and stopping, moving retrograde for a few months, as Earth overtakes it, still on the ecliptic, then moving prograde again.
But Mars doesn't orbit in the same plane, so it has some motion perpendicular to the ecliptic. when these motions are combined, the usual effect is a &quot;loop&quot; or sometimes an &quot;S&quot;.
(note that the axial tilt of the Earth is not relevant here)