This isn't really an answer, but likely the same way we've evolved systems to raise us from sleep when we need to switch positions in the night or stop breathing due to sleep apnea.
If a dolphin were studying a human, they'd probably be asking what sort of brain function can magically wake us up when someone pinches our nose closed in our sleep.
Per 2nd para, likely very similar system - just when we're roused we're not under water so are more likely to be able to act to recover our air supply.
If a dolphin were studying a human, they'd probably be asking what sort of brain function can magically wake us up when someone pinches our nose closed in our sleep.