The Earth orbits the Sun while the Moon orbits the Earth. The Earth also rotates about its axis once every 24 hours making an Earth day 24 hours long. The Moon also rotates about its axis. However, due to gravity, the Moon's rotation is such that the same side of the Moon always points towards Earth.
Moon
☀️ . o
Sun Mercury Venus Earth
*the space between each planet is not accurate to real life cause they are millions and thousands away from each other*