As seen from the Earth, the Sun, Moon, and planets all appear to move along the ecliptic. ... Unlike the Sun, however, the planets don't always move in the same direction along the ecliptic. They usually move in the same direction as the Sun, but from time to time they seem to slow down, stop, and reverse direction!
Because of various events in their (unknown) past history that resulted in deviations from the theoretical orbit. That formed in the plain of the ecliptic.
Capturing a large passing comet or asteroid might do it.