It's an evolved response the body does to conserve oxygen use in the brain. Consciousness shuts off, but the brain is still active. For example, someone who blacks out this way will not get water in their lungs--a part of the brain that is still active keeps your mouth shut so that no water is accidentally inhaled.
Freedivers try to avoid blackouts, but in this context, there are established safety procedures and it is not nearly as bad as you may think.
https://en.wikipedia.org/wiki/Laryngospasm
Before laryngospasm occurs water must enter the larynx. At which point, if you 're a few meters under the surface of the sea, you're in the process of drowing.
Think of it this way: if it were safe to lose consciousness underwater, if we had a magickal reflex response that kept us safe- why would anyone ever have to drown?
That is exact opposite of what I would intuitively guess. I would guess that it is way more likely that blackout means you body is getting injured rather then opposite.