I believe it's for the most part random. I recall once, I was allied to the Altarians while playing as the humans. The Altarians were at war with someone, so I joined in, too. The Altarians were weak, so they eventually crumbled. Guess who they surrendered to. If you guessed me because I was their ally and I attempted to save them from a war (almost did, too) you are wrong. They surrendered to the Drengin. Why?!??!
By the way, it wasn't the Drengin we were at war with.