I'm not sure what the problem, is. I'm also not sure your premise is accurate, that there are only ever two sides in a War. There are always shifting alliances and self-interest.
If country A is invaded by country B, country C may fight B, but only because it wants country A for itself. A may ally itself temporarily with C to rid itself of B, but may also covertly help B in places to kill as many of C's troops as possible, since it doesn't want C to emerge with any strength. B and C can therefore both lose in the sense they withdraw from the war when it appears unwinnable, and A may consider it has won. Or A may consider it has lost, since B and C have destroyed its infrastructure and left all its people dead or displaced. Or B and C may carve up A between them, so they both win, and only A loses.