The kind of dependable, predictable relationships between nations we all seem to desire in Civ is a fairly recent development in the relations between countries. Read up on some of the diplomacy that went on in the European middle ages, or among the warlords in medieval Japan. Side switching, backstabbing, and broken promises were quite common. More recently, Germany put an end to Hitler's non-agression pact with Stalin's Russia after less than two years by simply beginning an undeclared war. Trainloads of German grain were being delivered to Russia at the time the German attack began. I'm sure the German diplomats were gracious to their Russian counterparts the day before the war began.
I don't find this particular AI behavior especially unrealistic, but it can be annoying.