The rise and fall of sea levels—tides—are driven by:
The moon's gravity pulls ocean water toward it, creating a bulge (high tide) on the near side. A second bulge occurs on the far side due to inertia/differential pull.
The sun's gravity also affects tides, though its effect is about 44% of the moon's.
As Earth rotates daily, coastlines move through these bulges, producing roughly two high and two low tides per day.
Together, these forces create the complex tidal patterns observed worldwide.