Cavalry sort of tends to be more versatile and cost-efficient though. The upkeep of one unit of the larger types of eles - nevermind armoured ones - easily pays for several units of quite high-end horse cavalry.
Cavalry more versatile - definitely.
Cavalry more cost-efficient - yes, on average (not in big battles).
But Elephants in right conditions are unsopable.
You have the power of 4-5 high end cavalry units compressed inside one relatively small unit. It all can be delivered at once and on short front.
Cavalry cant match it. 4-5 cavalry units will take minutes to cause damage that Elephants can cause in mere seconds.
This is the ultimate weapon for destroying big and armour heavy army.
They cost their weight in gold but they are worth every penny.

I have nothing against cav. Its great and I use it all the time in quite big numbers. Usually cavalry is my hammer but I can appreciate elephants..