Do you really constantly count and succeed to memorize all of them? Would assisted computer recognition of disappearing bodies allow a lifeguard to watch a bigger beach? It seems like people constantly swim outside the dedicated flags, so it could be an improvement.
I did count okay, and attempted to remember people, especially those I wanted to keep track of: anyone on their own, weak swimming individuals, people who might have their mind elsewhere, etc. A whole count and a count of the groups was enough. But you're right, it changes constantly. It takes concentration.
People tend to get in difficulty particularly if they go out in a group (threes are the worst, ime), and the others move away or swim deeper, or come in. So I noticed problems more than once when a group didn't tally ('there were four friends there, where's the other one?')
Because of the property I ran, the count was feasible, but on a long beach or a packed facility it probably wouldn't be. We had around 50:1 ratio max. I tried a bunch of stuff with my team, but it was the thing that worked best.
There are bits of tech to do some spotting, and there are companies that do 'remote' lifeguarding (i.e. offshore people watching video, with an onsite guard in case something happens). I can't speak to the use of that, because we had state regulations that meant we had specific staffing structure.