I think the AI is generally ******** and wants to do that, I've noticed that too you just have to check every once in a while to make sure theyre on the right track
I don't really know how to put it but I've been watching that situation for some time now

The AI doesn't seem to look at the amount of

food > time to upgrade > commerce would seem to be the priorities imo
excluding player set priorities for the city like production etc.
food is furthermore only at the top of the list as long as the health/happiness limit of the city hasn't been reached, then it gets complicated
Generally the AI prioritizes a cottage until it's stage 2, then they'll start working water tiles(if they give 2

A cottage (just built, no river 2




Once the cottage grows the coastal tile is preferred even if it's a town with 2


or another cottage at stage 1 if there is one
I'm not sure but with free peasantry (100% cottage growth) I think the AI switches from the cottage to coastal after stage 2 (once it takes 20 turns to grow)
rivers/wharfs etc. bringing extra commerce might be leading me to a false conclusion though
the problem would be that a coastal tile shouldn't have a 'time to upgrade/upgrade stage indicator'
only 2 ways around that, don't build a harbor (only really an option in very few cases)
or
manual city production, I do that because of the GP management anyway
but since I've been using guilds/apprenticeship (or serfdom/manorialism)with pretty much every civ I've played so far I don't really build cottages anymore(beta 9)