When someone challenges your belief system, your brain goes into defense mode.
There are many reasons for this, but the base reason is the desire to stay safe.
You see, back in our hunter-gatherer days, our ancestors survived in small tribal groups.
To think the same was a mega survival advantage. To think differently was a liability. As a result, we easily succumb to groupthink and dogma.
To trust strangers could be a death sentence. Thus we have an innate distrust of strangers.
To casually stroll through the wild and not pay attention to every sound and ruffle of grass would surely be a death sentence after a while. We get negativity bias for this reason.
Finally, we cling to our beliefs because going back and forth on what you say could have threatened your status in the group. If your group couldn’t trust you to stay consistent and to contribute, you could be killed or kicked out (same as being killed).
This is why humans have such a hard time changing their minds.
And it’s why we so quickly polarize... we are tribal creatures... and we seek to fit the world into an easy to understand US vs THEM.