Dood declared war on me, started to fight on my capital hence locking the production of my capital

I spawned three different 4 man armies at different garrisons from one of my cities using money, as soon as the battle we were fighting was over I realised he had just walked in with his armies and took my second city passing directly over one of the garrisons that had an army I just spawned plus the army I had left on the city itself.

He was spamming elephants so I'm unsure if he used/exploited the autoresolve to instantly fight those 2 battles with the game not even telling me, plus winning a fight that he technically couldn't win cause as far as I know elephants don't go over walls, like chariots, but at the same time his archers where shooting me over a mountain and into my walled garrison when I need direct line of sight in mine so, whatever, I digress. Were my units not there for the Mughal or did he just exploit the autoresolve while I was fighting the other battle?