This reminds me of the political struggle going on during the life of the prophet Isaiah ben Amoz (Isaiah). If I recall correctly, at this point in history (around the 8th-7th Century B.C.,) Assyria has been expanding its power throughout the Middle East (and even as far as Egypt.)
Along with this expansion, Assyria has invaded Israel under the command of Tiglath-Pileser III. Isaiah sees the struggle going on between neighboring areas (caused in part by the pressure from the Neo-Assyrian empire,) namely, the disagreement between Ahaz, king of Judah, and the kings of Israel and Aram (Damascus) over how to deal with Assyria.
Ahaz does not want Judah to join with Israel and Aram against the Assyrians and soon finds himself attacked by Israel and Aram... and eventually, Ahaz, evidently, fails to defend against the attack. Ahaz then decides to ask the Tiglath-Pileser III for help against Israel and Aram. (Ahaz, of Judah, is asking the Assyrian empire for help!) As a result of the request of Ahaz, Assyria successfully attacks Israel and Aram; with many captives taken.
Assyria goes on to keep Ahaz as a sort of "puppet ruler" whose "kingdom" of Judah is safe from the Assyrians so long as Ahaz is "king".
When Ahaz eventually dies, he is succeeded by his son, Hezekiah. Hezekiah brings about much change and reform as he takes the throne. Hezekiah even resists the Assyrian empire (by entering into an alliance with Egypt,) unlike his father, Ahaz. But like his father Ahaz, Hezekiah is again asking for help from an enemy–or, at present, the enemy of his enemy.
As a result of this alliance with Egypt, the king of Assyria threatens Hezekiah and soon invades Judah; Hezekiah is defeated, and is ultimately forced to submit to the Assyrians.
War eventually breaks out, once again, and the king of Assyria sends more units down to Judah and Jerusalem. But this time, Hezekiah decides to turn to G-d. As a result, G-d hears his prayer, and Isaiah relays the message to Hezekiah that Judah will be saved.
It is then that the angel of the L-RD destroys a large number of Assyrians (as the Assyrian armies are camped somewhere, most likely, near Jerusalem,) to the point where Assyria has to retreat from its advance.
Going back to the question in the original post: looking back on the choices of King Ahaz, and King Hezekiah, both kings chose to ally with enemy nations. But in both cases, the kings (and their respective nations,) are the ones who lose. The enemy of my enemy may seem like a friend for a time, but, as uncertain relationships (whether professional, business, political, etc.) can often end in legal quarrels and lost assets, do remember that enemies are, most likely, still enemies.
Even when the choice to side with an enemy is done in order to prevent further harm, it does not change the examples of these choices and their results given in the historical accounts from the life and times of the prophet, Isaiah.