How does one program crashing not crash the entire system?
Probably you should read something about OS memory management.

If the program is running it has memory which is readable, memory which is writable and both. If it tries to go beyond its permissions, OS kills it and reports to you in a way you call "crash".

That's all was very roughly speaking.