I've seen this too. AI building cities on resources, river and swamp tiles, and quest locations. Same thing with outposts.
A while back, there was a post explaining a possible reason for this and similar behaviours of the AI. Certain game features (like settling and razing cities, building outposts, etc.) seem to be regulated by the UI. The AI, however, has no access to the UI, which means, that it doesn't get told, that it can't do this. I have no idea, if there is any truth to this, but it seems likely.