Suppose you're a caveperson walking in a forest with a problem, and that problem needs immediate solution.
Scenario 1: A large tree is suddenly falling crushingly towards you. What's your plan of action?
Scenario 2: A large tiger is suddenly falling crushingly towards you. What's your plan of action?
Hopefully, in scenario 1 you know to get out of the way of the tree to some distance of safety, where you can relax and calm down. Hopefully, in scenario 2 you know you need to get out of the way of the tiger, and then keep on running until you can lose, allay, or kill the tiger.
How do you know which response to use? Of course it seems obvious to us because we have common sense, but psychologists want to know the answer more fundamentally.
It turns out it has to do with the types of agency. The tree falling has mechanical or physical agency. Something mechanical caused it and once it's done it's done. It won't, once it misses you, rise up and try to fall at you a second time. Similarly, the angry tiger won't, once it misses you, just lie there. The tiger has intentional agency, an ability—like your own—to change its behavior to accomplish some goal, e.g. eating you. It will rise up after it misses and give ferocious chase. So, reasonably, we must have some method of immediately detecting what type of agency is behind perceived change.
For the sake of disclosure, Daniel Dennett, the original proponent these agencies, also describes a third type of agency called design agency, but it doesn't really play much of a part of this story.
It turns out that we do have in our brains neural systems for sensing types of agency, and psychologists call them (no surprise) mechanical and intentional agency detectors. What's interesting is, they're very distinct modules. The mechanical agency system connects primarily to the crude physics module in our heads that can predict the motion of billiard balls. The intentional agency system connects to our anterior paracingulate cortex, which is where our theory of mind is housed, and is tied into our sense of self, i.e. our own sense of agency. In other words, you answer "What does that tiger want?" by taking an intentional stance towards the answer, asking "Well, what would I want?" and combining it with your direct memories and indirect hearsay about tigers.
Now we return to the forest scenarios, but need to ask a different question. If evolution was to select for one or the other modules' being stronger, which would it pick? Well, let's swap our caveperson responses and see.
One caveperson's agency detector errs on the side of mechanics. She runs from the falling tree and stops. Fine. But she also runs from the tiger and stops. Not so fine. This caveperson dies.
The other caveperson's agency detector errs on the side of intention. She runs from the tiger and keeps running, believing that the tiger is just behind. Fine. She may live or die. She also runs from the tree and keeps running, believing it is chasing her. A waste of energy perhaps in this false positive, but not as dire of consequences as the other caveperson.
This thought experiment shows that if evolution has to select for one or the other, it will select for hyperactive agency detection. (I think a more specific term would be hyperactive intentional agency detection, but that's not the term that's being used out there.)
On the one hand, this is kind of cool because it gives us ghosts, and movies, and puppets. We ask, "Who caused that speech?" and our brain has no problem responding with, "Oh, that little doll." Yay for hyperactive agency detectors, we are entertained.
On the other hand, it's complicated by abstract thought and memory. We can construct nonsensical questions like, "Who caused that eclipse?" and our brain is ready to accept the shaman's answer "A celestial pig devouring the moon." Or we can ask "Who caused this universe?" and we're pre-selected to accept intentional agency.
To be specific, hyperactive agency detectors may be underneath our very concept of religion. Which is kind of cool because it gives us beautiful stories, and much needed comfort, and lovely painted spandrels, but we should be careful and skeptical because it also gives us Inquisitions and murdered doctors in Florida.