How does the moon affect the tides?
Gravity is what makes the ocean tides happen. Gravity is the attractive force that all matter exerts on other matter, and it’s what holds us to the Earth. All the matter that makes up the Earth attracts each other, and the result is that it pulls itself into this round ball, which we know as the globe.
If there were no other external factors, the Earth would be a smooth, round sphere, and the oceans would be the same depth everywhere and would never change. But our moon exerts its own gravitational force that affects some of our life on Earth.
The tides are the result of the moon exerting its gravitational force on the ocean and bulging it both toward and away from the moon. The tide is higher, the ocean is higher, at the location closest to the moon and on the opposite side of the Earth.
As the Earth rotates, the position relative to the moon changes, so the bulge moves. At any one location the sea level goes up and goes down as the bulge passes that location. Every six hours the tide goes from high to low and high to low again. Over 24 hours you typically see two high tides and two low tides.
The sun can also be influential.
The sun, if it happens to be aligned with the moon, also exerts a gravitational force and can work together with the moon to make the tides even stronger. If the sun is unaligned with the moon, then it works against the moon, reducing the high tide and raising the low tide a little bit so the peak and valley are not as large.
The process is more complicated the oceans have a shape, different depths and coastlines, so the water sloshes around in ways that causes the sea level to rise and lower by different amounts depending on where you are. Some locations, like the Bay of Fundy in Canada, see a sea level variation from low to high by as much as 50 feet. In much of the rest of the world, the variation is only a few feet up and down with each high and low tide.