You have to consider the diplo and tech situation very carefully before you decide who to attack, even this early.
Who were your potential targets? Being a pangea map it's almost certain there was more than 1 logistically realistic target. Pacal is often a good choice because he spends a lot of hammers on wonders that other leaders would be putting into units. But he also tends to be a tech leader, which makes him more of a threat to bribe other AIs onto his side.
Before you declare you'll want to look at the relations table, remembering to apply any "you declared war on our friend!" and shared war modifiers that will come into effect once you declare. Cross-referencing this information with AI leaderhead xml info lets you know who would be able to bribe who into war. You again cross-reference this to the tech trade screen to see who has the trading pieces to bribe if that option is available to them. Keep in mind that bribing someone into a war that's already happening is significantly cheaper than bribing to declare a new war.
This all seems like a chore, but there are several exploits that allow you to use this info to keep yourself safe. The classic is begging civs with which you are pleased for a very small amount of gold, or a low-value tech/resource if currency hasn't unlocked trades for gold. Doesn't always work but a successful beg gives you an automatic 10-turn peace treaty. So does accepting a demand from an AI, that can be very important in the lead-up to a war. If you know a civ could be bribed in on you, having them at pleased can save you. Getting them to pleased can be easier than you think. Civic/religion swap can do it, declaring a phony war for them can do it, and if all else fails you can gift them a city for an automatic +4 diplo bonus. The city has to be within a certain radius of their capital, I believe, unless it is very early in the game (I feel like it's before turn 50? But I'm not confident I remember that right).
It's also possible that in your game the AIs were not bribed, or at least not both of them. AIs are capable of backstabbing you on their own depending on your relations, power ratio, and that particular leader's programmed behaviour. AIs will "dogpile" you as well, which I seem to recall is because they look at the power rating of the AIs already at war with you when making the power ratio calculations? Again, I might be mis-remembering.
In any case like Izuul says you can almost always salvage a game on Immortal. You said you successfully took a bunch of cities before you got dogpiled and the new enemies have war elephants. There are a few strategies you could use to survive this:
-Spearmen defending cities against war elephants will get you a very favourable hammer exchange. They will lose more elephants than you will lose spearmen, at almost double the cost. Whipping walls in the city they target and whipping/funneling spearmen to that city should work.
-Cats as city defenders. Unless I'm mistaken they'll shield your stack from collateral damage when they are the active defender. Also very effective to suicide a cat or two or three into a stack just before they attack your city. This is easy to time because once the AI has cats in a stack they'll (almost?) always bombard your defenses to 0% before attacking.
-Trap city. This works well if you have CRII+ promoted cats. Let an AI capture a city from you that was not previously theirs. It will start at 0% cultural defense, they'll have no fortification bonus. You will actually get better odds attacking their stack in this city with CR promoted units (particularly cats) than you will attacking them in the open.
Losing a bunch of units in your territory will usually see the AI offer peace before long.