This is where “antagonistic pleiotropy” comes into play: the idea that a survival mechanism that is good for us when we are young is kept through evolution because this far outweighs any problems it might cause when we get older. Yes, natural selection is callous, but it works.