> Why would the brain evolve to do this? it has no evolutionary purpose.
Not necessarily. As another commenter speculates, this mechanism may help one remember a similar situation and thus find a solution to prevent death. The person can then go on to father another generation of people with this trait.