Pretty much similar thing happenend with me. I was playing as the Byzantines on the XL Mod. A massive Spanish army attacked me and I manged to camp on a mountain in a high pass, unassailable from all but one ascent. 8) they just camped, out of range of my catapults and milled around, "doing formations" with 3 units of Jinettes. Towards the end, after 20 mins of +100% speed, I sent in some Kilbanophoroi and my general to mop up the now very tired Jinettes (and so he didn't get that vice where he doesnt like to risk himself in battle ;) ).

I guess it happens when the AI tries to attack you from a better position, but fails to realise that it can't.