Machiavelli found the "enemy of my enemy is my friend" advice to be cheap and short-sighted, at least for a ruler. It is not that he was concerned with moral virtues, but rather he saw shifting alliances as ineffective in the long run, and fostering loyalties and respect as more effective. Better yet, converting enemies into friends (Ch.20 of the Prince). So he advises picking a side and sticking to it:
"A prince is also esteemed when he shows himself a true friend or a true enemy, that is, when, without reservation, he takes his stand with one side or the other. This is always wiser than trying to be neutral, for if two powerful neighbors of yours fall out they are either of such sort that the victor may give you reason to fear him or they are not. In either case it will be better for you to take sides and wage an honest war."
I doubt that Machiavelli would have objected to the original Kautilya's quip (trivialized into the enemy of my enemy proverb in 1700-s, long after Machiavelli's time), "a king whose territory has a common boundary with that of an enemy is an ally", but his contemporaneous Italy was not exactly a country of fixed boundaries. Of course, he not only had no objection to enticing others to follow the proverb, when it suits him (and exterminating them otherwise), but encourages it in his praise of Cesare Borjia from Discourses:
"He who considers it necessary to secure himself against enemies in his new principality, to win friends, to overcome either by force or fraud, to make himself beloved and feared by the people, to be followed and revered by the soldiers, to exterminate those who have power or reason to hurt him, to change the old order of things for new, to be severe and gracious, magnanimous and liberal, to destroy a disloyal soldiery and to create new, to maintain friendship with kings and princes in such a way that they must help him with zeal and offend with caution, cannot find a better example than the actions of this man.”"