Caffeine is slightly diuretic. (It increases your urination a bit.) So if you drink 8 ounces of coffee, you don’t get the same hydrating benefit as 8 ounces of water. You do get some hydrating benefit, it just isn’t clear how much.
In the case of a cup of coffee, I would assume that 8 ounces would give you a hydrating benefit of at least 4 ounces of water. In the case of energy drinks, the caffeine is so high that I’m not sure that you are getting any hydrating benefits.