No, Mars never changes direction. It’s just a line of sight thing. Earth orbits the sun faster than Mars does. So every year, Earth catches up with Mars in its slow orbit around the sun (two years for each year of Earth) and from our point of view it goes backwards relative to the distant stars. Like this:
Retrograde Motion (image by Brian Brondel) - this happens to either side of opposition - when the planet is the opposite side of the Earth from the Sun in the sky and visible all night.
This is what it looks like with the planet’s shown much larger than their actual size - video repeats several times
See this animation, using actual photographs of Mars and Saturn by Tunc Tezel
See also this wonderful composite photograph of the current retrograde motion of Mars on APOD APOD: 2016 September 15 which shows the final result at the end of the animation.
The same is true for all the other planets in the outer solar system: Jupiter, Saturn, Uranus, Neptune, Pluto,and anything else with an orbital period of more than one year including long period comets and asteroids.
Historically, this retograde motion puzzled ancient astronomers, as they thought the planets orbited Earth, and they developed systems of circles on top of circles to explain the planet’s motion. The modern understanding of this emerged slowly in the sixteenth through to the seventeenth century with the work of Copernicus, Kepler and Newton amongst others.
See also: