A friend and I were discussing this a while ago, and it just popped back into my head.
And what the hell, I thought I'd share it with you.
Your sound card, or more likely your sound card's driver, reads data from a portion of memory allocated as an output buffer for your audio. It's a ring buffer.
That means, the sound card plays whatever's in there, and when it gets to the end of the section of memory, it jumps back to the beginning and carries on.
So, as long as your system can update what's already been read before it gets read again, you won't get sound-looping.
But if something goes wrong and your system becomes less responsive than it should be... the buffer under-runs, and because it's a ring buffer it just keeps getting read out.
This post was brought to you by the fact that I'm a nerd, and wanted to show it.