The AI is just plain stupid, it can't make any "optimal decisions" at all.
Of course on levels like Imm/Deity they attack you, but look what they're attacking with? They are an age higher than you and all you get is warriors, spears and archers...sometimes catapults.
You have 3 archers and 2 warriors to defend that horde of 20 units, of course you win as you're the human. Kill 2-3 per turn and don't get killed is easy. BUT if they decided to upgrade their before an attack, then I (we) would be in trouble.
Just kill melees first!