expression

The enemy of my enemy is my friend.

Theme: cooperation Keyword: enemy

suggests that

people or groups with a common opponent may form a temporary alliance despite their other differences. Such an alliance does not necessarily imply genuine friendship.

Example

Two rival parties cooperated to oppose a policy that threatened both of them. The enemy of my enemy is my friend.