All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Your question consists of two things. First, going to the beach then swimming in the sea. As for going to the beach, it is lawful for men and women with Mahram as long as it is not accompanied by any Munkar (bad deed) such as nudity, alcohol, women mixing with alien men, music and singing. If it is accompanied by any of these Munkar it is forbidden just like any other place where these Munkar are done.
Swimming in the sea is lawful for men provided that they cover their Awrah (between navel and knee).
On the other hand, it is unlawful for women to swim in the sea as long as there is any alien man in the area or the area is a public place where men could come at any time to swim. It is also a condition that none of her brothers, sons or other Mahrams be with her because while swimming the woman exposes of her body what should not be seen by any man other than her husband.
Allah knows best.