The expansion of the universe and the motion of celestial bodies within it are two separate phenomena that occur on different scales.
The expansion of the universe refers to the overall increase in the scale of space itself. It is observed that the distances between galaxies are generally increasing over time, driven by the expansion of spacetime. However, the expansion primarily affects the vast distances between galaxies and galaxy clusters on cosmological scales.
On smaller scales, such as within our solar system, the gravitational forces between celestial bodies play a dominant role. Gravity is a fundamental force that attracts objects with mass toward each other. The gravitational interactions between the Sun, planets, moons, and other celestial bodies in our solar system keep them in relatively stable orbits around each other.
While the expansion of the universe influences the large-scale structure of the cosmos, the gravitational forces within systems like our solar system are much stronger at these smaller scales. The gravitational pull of the Sun keeps the planets in their orbits, and the interplay of gravitational forces between the planets maintains their positions relative to one another.
In summary, while the expansion of the universe affects the large-scale structure of space, the gravitational forces within our solar system dominate and keep the planets in their orbits around the Sun.