Janus is a small moon of Saturn. It is somewhat oval in shape and has a diameter of about 180 kilometers. Epimetheus is another moon of Saturn, with a diameter of about 120 kilometers. The two moons are very similar, even down to their orbits. They share the same orbital plane, and at the moment the orbit of Janus is only about 50 kilometers closer to Saturn than that of Epimetheus. In other words the gap between the orbits is less than the size of the moons.
You might think this is a recipe for unpleasantness. After all, since the orbit of Janus is closer to Saturn, Janus moves around in its orbit faster than Epimetheus. So over time Janus will catch up to Epimetheus, and would overtake its sister moon if it weren’t for that fact that it is in the way. Surely it’s only a matter of time before the two moons collide.
Except that isn’t what happens. Instead of an imminent collision, the two moons do a little dance. Janus and Epimetheus are not only of similar orbits, they are of similar mass. Similar in this case means that Janus is only about four times more massive than Epimetheus, rather than hundreds or thousands. So as Janus begins to approach Epimetheus, the gravitational pull of Janus will cause the orbit of Epimetheus to get a bit smaller. As a result, the speed of Epimetheus will increase. Likewise the gravitational pull of Epimetheus will embiggen the orbit of Janus a bit, causing it to slow down. You can see this in the figure.
So instead of colliding, the two moons do a gravitational dance where they effectively exchange orbits. Janus catches up to Epimetheus (to within about 10,000 kilometers), they do their gravitational dance, and then Epimetheus races ahead of Janus. Eventually Epimetheus catches up to Janus and another dance brings them back to where they started. This exchange happens about once every four years.
A magic dance, driven by the force of gravity.