The brain is an organ. Like any organ, it has a design function. The design function of the brain in all organisms is survival of the organism. The brain does very little else.
In human beings, the functional design of the brain is survival of the "self." Animals have no concept of self, but humans do. If you consider yourself to be your strongly held convictions and beliefs, your brain will cause you to do whatever you need to do for them to survive: even sacrifice your body. The mass of nerve cells we call the brain figures if your principals survive then your self survives. So, we give our lives for God and Country.
If your brain (mind) considers your "self" to be your body, you will sacrifice your convictions and beliefs to save your body. You will lie, cheat, steal, even kill, whatever it takes. The brain figures that if your body survives, you survive. After all, it tells us, when the danger is over we can go back to our beliefs and opinions full of sound and fury; signifying nothing. (Apologies to Shakespeare)
In addition to past experiences and your point of view about them, an important (maybe most important) piece in the composition or collection of stuff the brain considers to be the "self" is the righteousness of your convictions. If your beliefs are correct, the self is intact. That's why it is so difficult to change your mind, or stay on a diet, or be wrong. The mind says "That's not you!" and you revert to old habits.
The short version is that the mind, in its single job of "self"-survival, has a big problem with being wrong. So, if you don't agree with me, you must be wrong, and I will go so far as to fear, hate, and even kill you to prove I'm right.