Both are correct.
One is “on” the beach when one speaks of being on the sand (as opposed to being in the water.) One is “at” the beach when one speaks of going to that location or being at that location (as opposed to being at home or at work.) When one is “at” the beach, the water is included in the idea, but as humans are land-based life, one assumes that the water is a temporary thing and that most of the time is spent on the land, or at least, that’s where one went for recreation. That the recreation involves being in the water isn’t important; that recreation started on land.
At the beach is less specific, you might be literally on the beach, or you might be visiting some nearby attraction, like the boardwalk, or a mall. On the beach implies you are literally in the sand at the water’s edge. Unless you’re in the Navy. Then it means you are on land somewhere, and not at sea.