the source of the fear can’t be entirely evolutionary—I could be not the least bit afraid of the dark in normal life but become very afraid when in a supposedly haunted area.
The human brain has evolved several mechanisms that are useful for detecting other agents, but which sometimes produce false-positives. For example, we have some sort of hardware specifically dedicated to recognizing faces (presumably detect the pattern of two eyes, a nose and a mouth). There exist people who have damage to their brain such that they seem mentally perfectly normal, except that they have trouble detecting people in photographs, for example.
When this hardware produces a false positive, then at some (subconcious?) level, you are detecting that there is someone here. But when you use your conscious mind to scan your environment, you don’t see anyone. This is what causes unease, and the feeling of “hauntedness”.
I believe there’s also a part of the brain which has evolved to detect agency (perhaps to help with dealing with “Theory of Mind” and emulating other people’s minds for social purposes?) and “false positives” in detecting agency may be one explanation of religion.
I used to be pretty good at this videogame called Dance Dance Revolution (or DDR for short). I’ve won several province-level tournaments (both in my own province and in neighboring tournaments), did official internet rankings and ranked 10th place in North America, and 95th world wide.
People would often ask to play a match against me, and I’d always accept (figuring it was the “polite” thing to do), though I had mixed feelings about it. I very quickly realized it was a losing proposition for me: If I won, nobody noticed or remarked upon it (because I was known to be the “best” in my area), but I figured if I ever lost, people would make a big deal about it.
I often self-handicapped myself. I claimed that this was to make the match more interesting (and I often won despite self-handicap), but sometimes I wondered if perhaps I was also preparing excuses for myself so that if I ever did lose, I could blame the handicaps (and probably do so accurately, since I truly believe I could have beaten them in a “fair” match).
I had the fortune of traveling to Japan and a DDR player named Aaron who had ranked top 3 worldwide. He agreed to play a match with me, and I won the match, but it was very obvious to both of us that I had only won because of a glitch in the machine (basically, the game had unexpected froze and locked up, something I had never seen before, but when the game unfroze, I had been lucky and anticipated this before Aaron had).
So after the match, I turned to him, pulled out my digital camera and jokingly said “I can’t believe I actually beat you. I gotta get a picture of this.” But he had a rather serious look on his face and said something like “No, no pictures.” I was a bit surprised, but I put away my camera. We didn’t talk about it, but I suspected that I understood how he felt. I often felt like my reputation as the best DDR player in my province was constantly under attack. I figured he felt the same way, except world-wide, instead of provincially.