https://www.youtube.com/watch?v=cPouwOKMS2s
Young planets trade angular momentum with the gas disk they form in, so their orbits can drift inward or outward.
Saturn’s interaction with Jupiter and the disk is part of why the giants are not where they first condensed.