Mar - sea - is both masculine and feminine according to the dictionaries.
In the inland of Spain, people use ‘el mar’.
On all the coasts of Spain, people use ‘la mar’.
Why does that happen?
Simple reason: on the coast they know the sea is unpredictable, irascible, problematic, can kill without reason etc., so MUST be feminine.
Inland they don’t know any better.