Apparently nobody's mentioned this, but AI armies will sometimes exit the battlefield without a fight even when they don't have the option of retreat, so they end up losing all their units.