There are more advantages to alliances, besides preventing your enemy from signing them up against you, it also prevents them from trading with your enemy. Plus, they would break any deal they already have with your enemy potentially ruining their reputation. (if they haven't done so already)
And even if they don't put up an offense, it is still possible your enemy will try to put up an offense against them, and thus spend less resources vs you.
But at higher levels, you should be careful, if your enemy is able to overrun your ally, it will make him even stronger.
Also, there is a chance that the two enemies start singing up alliances with even more civ against each other, thus further reducing trading. You can them trade your stuff more easily with all those civ. This could continue, even after you've made peace with your original enemy.