Scuba mc, you got two very different events, and from the outside, they look the same.
Your second example is classic panic...the drive to remove yourself from the situation. There is an adrenaline rush to power it and at most it will last less than 2 minutes. Practice, experience and knowing what to expect and it is possible to control it completely. I never do a dive trip without taking my mask off, as I have never liked the feeling, so I control the feeling by practice.
The first one is a very different situation. CO2 build up will cause, in everyone, a panic response. It is you body telling you, that you are suffocating and will die if you continue on this path. As long as you have the higher CO2, you will be driven to bolt away. If you can reduce it, one is back in the standard panic mode. But if you cannot, this will not stop and no amount of practice will prevent this from happening.
This is made much worse by the potential for much higher CO2 levels because one is under higher pressure, so one can have a super case of flight.
If your person did it to themselves and then started breathing well, it would clear up, but one would still have the less than two minute panic. Clearly, bolting to the surface has a lot of other risks and long after the drive is gone, they may be dealing with those.
But there are lots of other reasons for CO2 build up, including CO2 in the tank (which might only show up at depth). There is edema's, Larynx spasm, equipment issues and don't forget that mild heart attack. One might start out with something not working correctly, then build up CO2... and there one goes.
It is, easily, the single biggest cause of diver deaths, not directly, but from the actions the diver takes from it. And this is not something one can practice to prevent. As a side note, after talking with the two doctors that did the research for the Navy, just doing a practice of it can cause terrible mental side effects and post traumatic issues...this is something one wants to avoid if at all possible.
All one can do is fight the drive, and just like Navy Seal training, evaluation the situation and convince yourself to do what is right and that you will only have to fight it until you get out of the situation. Some would be resolved on the surface, some will need medical attention and O2, but your life may depend on it.
Can a dive buddy help..absolutely not. First because they will not know what the right thing to do is (go to the surface as fast as you safely can, or go to the surface as slow as possible). I know in my event, had someone thought I needed to go to the surface, I would have hurt them. and with as much force as I could have. And second, this unrelenting panic will cause the person to fight harder (not good when you already have too high CO2. This is something the person has to deal with and it is terrible.
I should point out that I have, as an instructor, held people down from bolting to the surface a bunch of times...and I was lucky that all of those happened to be the standard panic. Not because I evaluated what was going on and then acted, but because I have always thought that you do that. I now know that if it is CO2 build up, you should not. Tough to do, but you will have no way to know what the right thing to do is, and you may, while trying to help, kill them.
Interesting to me is that the Dan research people know about this, but somehow it gets rather missed, and because they say just to give the person O2 and assume the worse, it is the right thing to do.
It might help to understand what to do and what is right to do, but it will not stop or change the feeling you get.
As you pointed out Nitrox is much worse, as you now have pressure and concentration.
I recently witnessed an experienced diver panic. Diver aborted dive and ascended rapidly from 15m for no clear reason. He later reported he couldn't catch his breath no matter how hard he tried to relax and breathe deeply, this was on OC 21%. I believe he created some CO2 build up, possibly from skip breathing, he is one of these people who is obsessed with improving his SAC anyway possible, including skip breathing. He often surfaces with headaches.
Years ago I also witnessed another experienced diver who had his mask strap break at around 20m, his mask completely flooded which sent him into a panic, he ended up surfacing. Later he admitted he hadn't practiced full mask clearance since he got certified, which turned out to be nearly 10 years earlier.