When your world disappears as a side effect of a crash like that (it seems to sometimes happen with any crash; there aren't particular bugs that always delete worlds) it means Minecraft has deleted level.dat but everything else is still there. (And no, I don't know why Minecraft deletes level.dat. Maybe it means it crashed in the middle of autosaving).
When you create a new world Minecraft reuses the same save location, since it thinks there isn't already a world there. But when it goes to generate the world, it realises there are already chunks saved, and loads them instead of generating new chunks. (More accurately it doesn't "go to generate the chunks then realise there are already chunks" - it loads the spawn area using the normal chunk loading mechanism, which generates chunks if they don't already exist, which just happens to be almost always in a new world - but that's not important).
This hasn't happened to me recently so I don't remember whether you keep your inventory when doing this. If you do, then it's because even though your inventory isn't saved in level.dat (because that was deleted and recreated) but it is saved in players/yourusername.dat, for compatibility with multiplayer saves. So it loads that.