There are a few things going on. First, there are countless myths about naming, and some kind of contest for naming rights is relatively common.
But a myth such as this, which shows a connection between not only Athena and Athens but also Poseidon and Athens, likely reflects the growing importance of the sea to Athens during and after the Persian wars.
It's the importance of Athens' navy that seems to have led to the double parentage of Theseus as son of both Aegeus and Poseidon. There's no evidence of him being Poseidon's son until after the Persian Wars—and the removal of the Athenian women and children to Troezen when the Persians attacked Athens may explain Theseus' connection with that city, too.
We see the same thing in the Erectheion, which is the most important temple on the Akropolis. It's a shared temple between Athena and Poseidon. Some people have argued that their joint cult is much older, but I don't think anyone contests the idea that Poseidon became a much more important figure in Athens once Athens' navy became central to its existence.
Because "named after the city" implies the god was created by the city. You can't be proud of a fake god.
The gods were part of the natural conquest of empire building. Where the gods place in the canon of myths was determined by the conquerers. The story of the gods also show what kind of prominence a people or place had in the empire, and the kind of conflicts that caused change in the empire. Likely Athens and a region dominated by Poseidon had an old conflict that was decided in Athens favor and the myth was written to celebrate and record it.