Why does the ocean move in and out?

Tides are mostly the Moon’s gravity pulling on Earth’s oceans, making bulges that sweep shores.