This is the core of the game's AI.
When they go to war, they go balls to the wall, no exceptions. You can absolutely crush their invading army, you know it'll be back, manpower or not. It doesn't matter how completely useless the war is to their personal needs or goals, if they're at war with a player, they're going to deplete any and every available means to continue this war to the fullest until peace is made, no ifs and or buts about it! This lack of any ability to just not give a crap is probably the single most crippling facet of the game's AI. It's worse because they clearly know to not care when fighting in certain engagements, especially ones requiring naval resources to continue (HYW once driven off, many ai venice vs ai whoever wars, the ai will just sit back and lose rather than land troops, even after patch), but they refuse to exercise this judgment and sit back if a human is involved. It becomes trivial to just obliterate the manpower and possibly navy of an ai, ally or enemy, by abusing the fact that they never give up never surrender!
Exacerbating this is that the ai, in these ai vs ai wars like the HYW where they clearly appear resigned to take the loss... they still won't surrender quickly. They use that very basic strength, warscore, and length of war formula even though it's clear they know their butt is kicked and they won't join any new wars because of the situation.
Solution: The AI needs to use some formula to determine if it should actually contribute meaningfully or not during a war, rather than only deciding when asked to join. It should not ALWAYS attack the player, and more importantly, it should not always attack FOR the player, when it is not really in its own best interest. AI should not do dumb viking style raids vs humans that it would not do vs another ai. They should definitely stop going on the offensive when manpower is low - if they wouldn't join an offensive call to arms because of low manpower, war exhaustion, or debt, don't have them go helping in a current war simply because they're in it; stay home.