How does the moon affect ocean tides on Earth?
The moon's gravity pulls on Earth's oceans, creating a bulge of water on the side of Earth facing the moon. Simultaneously, a second bulge forms on the opposite side of Earth due to inertia, as that water is effectively "left behind" by Earth being pulled toward the moon. As Earth rotates, different locations pass through these bulges, experiencing high tides roughly twice a day.
The sun also influences tides, though less strongly than the moon. When the sun and moon align during new and full moons, their combined gravitational pull creates stronger spring tides. When they are at right angles during quarter moons, their forces partially cancel, producing weaker neap tides.