What causes undertows?
When a wave breaks and then rushes up the beach, it leaves the water on the beach with excess gravitational potential energy. That’s what’s left of the wave’s energy. The water accelerates back down the beach and returns to the sea. This returning flow of water tends to go under the sea’s surface, probably because of the water’s circular motion in waves. Remember that the water in a wave travels in a circle, always moving forward (in the direction of the wave’s motion) when it’s at its highest point and backward (away from the direction of the wave’s motion) when it’s at its lowest point. I suspect that the returning flow of water from the beach joins this backward moving low water. When this low-lying returning water flows past you, it tends to sweep you along with it, hence the name undertow.