It can also be very useful as a canal for ships to move through rather than around large islands.
For defence though, it doesn't have to be just where the terrain is one square wide - if you have a place 3 squares wide and put a city in the middle, the AI will attack that city rather than move past. So a mountain or hill city like this works well too. Although spies might slip by to steal stuff from other cities.