The full explanation for how it works gets technical and understanding it means that you really need to get out more, but it is basically an exploit that enables code execution within the game itself.
It only works on the original DOS-based Doom 2, and not any of the more modern ports like GZDoom, which lack the exploit to avoid people spreading bad code.