I have read an entire book about brain hypoxia. From everything I read, it does not appear to be a defense mechanism at all. It is simply a matter of energy failure.
The neurons in the brain require certain electrical gradients in order to do their job as neurons. Maintaining the electrical gradient requires energy. The energy comes from ATP (adenosine triphosphate), which stores lots of energy in the phosphate chemical bond. The brain gets ATP from several sources, including:
1. Stored ATP in the brain (very small, enough for 3 second of consciousness)
2. Stored creatine phosphate in the brain (which can generate ATP, enough for 3 seconds of consciousness)
3. Burning O2 with glucose or ketone, generating ATP (requires oxygen supplied from the blood, as well as either glucose or ketone, also from the blood)
4. O2 stored in neuroglobin (very small --just discovered recently)
If #3 is cut off (from either holding your breath too long, or being strangled or choked), then you have enough energy from #1 and #2 to maintain consciousness for 6-7 seconds. This is why in the old days when people had their heads cut off (guillotine), they remained conscious for 6-7 seconds, and responded if you called their name by looking you in the eye (even after their head was cut off).
Once all these energy sources have been exhausted, there is no more ATP available. Burning glucose anaerobically (without O2) creates lactic acid very fast, and generates very little energy, enough for maybe 1 second of consciousness.
Once no energy is available, the neurons lose their electrical gradient and 'depolarize'. The process creates a chain reaction called 'anoxic depolarization'. When neurons no longer function, consciousness cannot be maintained, because the brain simply isn't working properly anymore.
The moment when blackout occurs depends on many variables, including blood pressure, hydration, brain creatine stores, carotid artery width, and so on. Because the moment of blackout can vary dramatically (either very early or very late), it seems even more likely that it isn't a defence mechanism. If it were a defense mechanism, then it would not be possible to develop tolerance to brain hypoxia and delay the blackout. If it were a defence mechanism, why not just black out nice and early to 'save' the organism?