"The men of Wu and Yueh hated each other, however, encountering severe winds when crossing a river on the same boat, they assisted each other like left and right hands." Sun Tzu
First, being concerned about future battles when you are currently fighting the one in front of you is hardly practical. Focus and resolve what is before you first, and then tackle the next problem when it comes. Problems never go away in life. They are simply different ones.
Second, resolving the current battle can forever change the direction of the war. It is what we call a one-point trend. When you have a problem as dire as a war, you will take the first positive outcome anytime, anywhere. Thus, when you can win without fighting, it permanently affects the perception of both you and your opponent now and in the future. The chances of a prolonged conflict have been significantly lowered.
Which brings us to why enemies can work together. They can work together because it is in their best interests to work together. Do people make irrational decisions? Yes. Do people always make irrational decisions when you change their perception? No.
Therefore, whether the agents of change in perception are massive severe winds as described in The Art of War or everyday simple acts of kindness, they shock the hostile system sufficiently to make everyone reconsider their beliefs and mindset. When enough evidence contradicts prior perceptions, those prior perceptions will slowly but surely shift. This is how trust begins.
Before you can have someone trust in you, it is imperative that you must first and foremost trust in yourself. You must trust in your ability to not give up when the going gets tough. You must trust in your ability to remain strong when others are apathetic to your call. You must trust that you are the leader you have been waiting for, and the leader that others have been waiting for -- even when popular individuals who others admire are actually devoid of leadership. Your time will come but only if you are still game and are still in the game.
Two enemies working together means that they have changed their views of each other. They are no longer enemies for this moment in time. And God willing, they might just remain that way in the future too if they both employ leadership, trust in themselves, and thus trust in each other. They would have no enemies under Heaven.