As stated by Sbroadbent, you should start by ending your war with the first faction, asking a ceasefire...

Then you should try to get as good a standing with the faction (giving gold, territories, trade rights or whatever...)

Then when you resume your attack, hope for the best...

That's the best way (and I think only way) to do it...

But I don't think it's worth the bother...It will cost you a lot and rarely have I seen allied faction strike together against me or even declaring war because I was at war with one of their allies...

In that matter, MTW2 is totally different from RTW in a diplomatic point of view...

Allying with a faction will not either end a war between that faction and another of your allies as it did in MTW... No more U.N.O. in MTW2...