It's very simple really, our brain is always looking for sensory input to interpret so we can figure things out about the outside world, it's been a huge survival advantage for billions of years now. So when you're unconscious there is no input coming in, or what there is is very much blunted and dull, but what there is are random electrical surges shooting around your brain between the various bits with no actual external input to drown them out. So our brain puts together a narrative to try to make sense of it all. It's exactly the same as when someone is sensorily deprived in say solitary confinement, they start to hallucinate and so on.