Here's why:
* Constellations are patterns of stars. They are simply groups of stars that appear close together in the sky from our perspective on Earth. They are vast distances apart, and the stars themselves are relatively stationary in relation to each other.
* Planets orbit the Sun. They are constantly moving in their own orbits around the Sun. This movement is what makes them appear to wander across the sky.
* Planets appear to move through constellations. As planets move in their orbits, their position relative to the background stars changes. This makes them appear to move through constellations over time.
Therefore, planets don't really "wander in and out" of constellations. They are constantly moving through them, appearing to pass through different constellations in their orbit around the Sun.