Why it runs backwards
Earth circles the Sun in a year. Mars takes 687 days. Every 26 months Earth catches up and passes Mars on the inside, like a faster car on the inner lane.
Watch the line of sight from Earth through Mars to the distant stars. Most of the time it sweeps forward. As Earth draws level, the line swings back for a few weeks. That backwards swing is the loop. Mars itself never reverses.
The loop opens up and down because Mars' orbit is tilted about 1.8° to ours, so it sits a few degrees north of the Sun's road during the pass.