My understanding is that it is a sin to knowingly subject yourself to an occasion of sin.
Picture this... a man who has a vice of impurity, who knows that if he goes to a certain website, he will be tempted to go to one linked to it where he can see impure pictures. He knew with fair certainty that would be the result before he went. If he goes anyway, he surely commits a sin.
A beach is such an occasion. It's a matter of both how people are dressed AND how they behave! If you are there, you (and your family/children) cannot avoid seeing these things around you. You know this before you go. Why go?
A sad side effect is most of us Catholics probably do a lot less swimming these days, but really, it is much better if Catholic swimming is done somewhere private (eg, only Catholics will be attending) and those in attendance have modest swim wear (even harder than finding a place to swim privately). This way you know that everybody will be modest, nobody will be exposed to certain temptation. A family swimming pool is a good idea, or maybe a lake.
But I think when we look at the matter it becomes clear, even if it means we simply cannot swim in our circuмstances, to expose oneself or others to occasion of sin is obviously sinful. If you go to swim thinking the place will be deserted, and a crowd of bikini babes suddenly storm your private get together... then the occasion of sin isn't your fault.