A coastal city (i.e. a city whose City Center is on a coastal tile) can produce naval units, but is subject to attack by naval melee units. A coastal district or tile improvement is subject to pillaging by naval raider units and any other naval unit that can perform Coastal Raids.
Thanks to the mechanics of the Harbor district, it is possible to build an inland city that can build naval units like a coastal city, but is not subject to attack by naval melee units. However, such a city must be located within 3 tiles of the coast (the maximum possible distance for district placement).
In Gathering Storm, coastal lowland tiles are given a Coastal rating of 1-3. This number indicates how high they are above sea level, and when they will be flooded and submerged by rising seas as the world's climate changes.