That sort of thinking has led to a lot of trouble.
Let me give a few examples from recent history.
After the USSR invaded Afghanistan in 1979, the US started arming and training anyone willing to fight them. This included a large group of religious zealots who opposed the atheistic Communist regime supported by the Soviets, as well as many foreign fighters, most also motivated by religion, who went to Afghanistan to join the battle.
We got what we wanted; the Russians were pushed out of Afghanistan.
We also got what we hadn't expected -- the Taliban (the native Afghan religious army) and al-Qaeda, which sprung from the band of foreign fighters who had gone to Afghanistan (including Osama bin Laden, who didn't fight but did organize and recruit actively during those years -- with US knowledge and encouragement; after all, the enemy of our enemy is our friend)
You heard me right -- we assisted in the creation, training and arming of the Taliban and al-Qaeda.
At about the same time, war broke out between Iran and Iraq. This was in the immediate wake of the hostage crisis, and we considered Iran an enemy. So for most of the next decade, we gave arms and other aid to Iraq.
Saddam Hussein's Iraq.
When the Gulf War was fought in 1991, the Iraqis were fighting our forces with weapons we had given them, and even today, young Americans continue to die in a war that began because we wanted to get rid of the man we had helped build up in the first place.
Choosing friends solely on the basis of having common enemies has a way of coming back to bite you.....