Individual cities will switch allegiance if they are in Civil Disorder or if the balance between happy and unhappy citizens is even (...). Occasionally (...) these "malcontent" cities will look to see where the grass is greener among their nearest neighbouring cities. When they find the nearby city that is happiest, they will annex themselves to that civilization. Usually (...) these will be the original owner's cities (because cities in a civilization's heartland tend only to be near other cities belonging to that same civilization). However, "border" cities will be vulnerable if they are next to other, "happier" civilizations.
This certainly sounds adequate, except for the "nearest neighbouring" and "nearby" part, since cities often flip from half the globe away without even knowing you're there.
Now, about the cities that cause the flips. I often do a monarchy play where I bump up my core cities to republic levels via WLTKD and trade. I get the most flips im my games that way, which leads me to believe that:
A) In order to get a flip, your city has to be celebrating. I believe that this is happening to me more often when I play monarchy, because when you run republic or democracy you tend to grow with WLTPD only for a few turns and then switch your luxury rate back to probably 10%. When you do a souped up monarchy, you keep at least 20% or possibly 30% lux. so you have a couple of big cities celebrating all the time... Which leads me to point B:
B) You not only have to be celebrating, but the enemy city has to be revolting... But that happens all the time and I think if those are the only conditions flips would be a much more common phenomenon. I suspect that it might have more to do with the number of consecutive turns the enemy city is in revolt and maybe some of the special events like 'rioting in ###' or the even more cryptic 'scandal in ###'.
I've been playing Civ on and off since 1994 and I've gotten hundreds of flips but only a few did occur in a geographically sound manner, i. e. actually near my borders and my prospering city/ies. One most astounding case was when I got two flips of the same city in a span of a couple of hundred years. Relying on the aforementioned monarchy play I'd gotten Rome, Caesarea and Chartage up to 20+ with trade, banks, celebrations and everything, and I had blockaded the Zulus with whom I shared the continent with a sound system of a couple of forts and a big garrison.
The city that was facing my fortresses defected. It was on the same isthmus that I had blockaded and only several squares away from Zimbabwe. The only thing separating me from the Zulu capital was a small mountain range where I intended to build another fort and use it to press Shaka into submission by keeping my guns constantly pointed at his palace. I almost succeeded, but he managed to retake the city. In a few turns it flipped to me again.