Ahh, the classic blowup hole. First of all, realize that we all have these moments. A bogey free round is a rare accomplishment, and we are all likely to simply receive a little bad luck during a round that will cause us to take a bogey. But double and triple bogies are another story. So how can we stop the bleeding? First, slow down as soon as you're in trouble. Realize the inevitable is about to happen and you are going to take a bogey. We all want to save par as soon as we shank one deep in the woods, but use your best judgment. Realize that your anger at this moment will likely keep you from playing smart. Don't rush that next shot. Analyze all your options and try to think of the odds of making each shot. If you're not confident you can hit the three foot gap 200 feet away, suck it up and pitch out. Now finishing the hole without any more mishaps unfortunately just comes with experience. You're probably going to be a little flustered at this point but you have to play through it. Try to remember similar shots and putts you have made successfully. Be positive, you have made these shots before, and you can do it again.
As far as practicing for these moments, play your bad shots in practice rounds too. We typically throw multiple drives in a practice round, but don't always take your best shot. Getting out of trouble is a skill too (although not getting into it in the first place is a better skill). But the more you practice trouble shots, the more comfortable you will feel using them in a round. Then you might be able to save that par after all.