There's more to it than plan your dive and dive your plan.
When people were dropping like flies in caves, a local instructor decided to take a look at what was killing herds of divers. He came up with the top 5 reasons people were dying in caves. Here's the list in order of importance (or rather greatest cause of fatality to least cause of fatality)
Training -- Have It
Guideline -- Continuous throughout your dive all the way to the surface
Air (Gas) -- At full cave, use 1/3 of your gas supply heading in, leaving 2/3rds to exit, in case of emergency
Depth -- This used to be 130', but has morphed into: What depth YOU'VE been trained to dive to (Nitrox, Trimix, Ext Range Trimix, etc.)
Lights -- At least three
You'll notice that this instructor found the number 1 cause of depth in caves to be lack of training. It's killed open water divers, open water instructors, intro to cave divers, and beyond. If you don't have training, you really stand a good chance of dying in a cave. Training will teach you what can go wrong and why, how to look out for it, how to fix it even if what can go wrong does. Training teaches you what gear to use and why we use it. Training exposes you to dozens of obstacles and hazards and shows you how to overcome them, because I promise you that if you dive enough in caves, those hazards WILL happen to you. Training teaches you about complacency (the true killer in cave diving). It teaches you how to guard against complacency. It teaches you how not to get lazy. Ultimately, training teaches you how to live.
The second greatest number of fatalities came from people not having a continuous guideline to the surface. Imagine making the same dive 500 times. You know that cave like the back of your hand, so you get complacent and decide this time you don't need to run that 40' of line. Well, guess what, that's no.2 on the instructor's list for killing people, even trained people. Honestly, you don't need a guideline to get into a cave... You need a guideline to get out of a cave.
The third most significant killer: Gas management. People cheat their gas all the time. I've probably caught 4 dive buddies this year that were beyond their turning pressure when I looked at their gauge. THAT'S MY GAS!!! In the event of a catastrophic gas loss, that extra 2/3'rds are to get your dive buddy out, or to get you out if you lost your gas. Don't cheat it. It can kill you, or your buddy. What's a Ducksworth?
The rules about depth have morphed over the years. When I began cave diving, there wasn't Trimix classes. Hell, Nitrox was still being called the gas that would kill everyone by PADI and others. We were told that we shouldn't cave dive beyond 130'. Today, the most accepted rule would probably be don't have an END of greater than 100'. I agree with it mostly. Diving deep could kill you.
The last rule was lights. Have 3. Preferably a very powerful primary light. Murphy will come. It's possible that you could have a light failure. It's possible you could have two light failures. Hell, it's even possible you could have three light failures. But if between you and your dive buddy you lose 6 lights, well dude.... I'm sorry, God wanted you dead. You're not going to change his mind, you're not going to bargain with him, or talk him out of it, your number is up. Interestingly enough, if you've followed RULE 1, you can survive a cave dive without any light. Guess what! We're taught how in our training.
Anyway, I hope this help. Oh, by the way, for those of you who don't know, the instructor who came up with this list, and wrote the book about it was named Sheck Exley.
-edit-
I would also like to add this:
With the exception of Parker Turner who died from a ceiling collapse in a cave, no one has ever died from cave diving obeying all 5 rules listed above. I say "no one has ever died from cave diving because someone could have suffered a medical issue like a heart attack. But if you look at the causes of death for every cave diving issue (with the exception of a collapse) every single death could be attributed to not following one of the above rules. What that says to me is this: If you follow all 5 rules, you have virtually a 100% chance of surviving. And that, my friends, is pretty good odds.