In Traits, AN 4.192, a personal identity (i.e. our self-image) is a result of living in a society. And the consequence is that we are swept away by gain and loss, fame and disgrace, praise and blame, pleasure and pain.
Once, we have an identity view, we will want to do whatever necessary to defend and build on it. Anything that threatens our identity/image/esteem is clear and present danger. Anything that can assuage and boost our self-identity is dear and precious. That’s why we surround ourselves with things/activities/people that result in gain, fame, praise and pleasure. Similarly, we avoid and resist things/activities/people that cause loss, disgrace, blame and pain.
To me, therefore, being narcissistic, self-centered and egoistic is a desire arising from having an identity view taken to extremities. It is still about defending and building on our self-esteem, image...our very existence. One way to see this clearly is to look at the opposite, people with extremely low self-esteem i.e. inferiority complex. In such situations, we essentially hate ourselves. We will attack (instead of defending) and tear down (instead of building) this disappointing self. It’s really a malfunctioning situation that I hope no one ever needs to go through. Although I believe at some point in our lives, we go through some episodes when we despise who we are.
But why do some people ended up being narcissistic, self-centered and egoistic while others suffered from chronic feelings of inadequacy, insecurity and inferiority? I am not a psychologist or psychiatrist so the following is based on my observations. I believe it’s partly karma because past karma pre-disposed us towards certain ways of thinking, speaking and behaviour. It’s also partly our choices because of our preferences for certain ways of thinking, speaking and acting which in turn generate new karmic seeds that affects us in the future.
Personally, I learned to just move away from narcissistic, selfish and egoistic people. They have their habits (or preferences) and if they are not willing to change themselves then no external forces can do so for them. One curious thing I observed is that such people seldom admit what is their true desires. I strongly suspect that they may even not be conscious of their true intentions having habitually hidden them so deep within themselves. But desires (and intentions), whether hidden or not, guide our actions in certain directions in order to achieve certain results. Consequently, when such people are questioned on their actions, they are forced to engineer some storylines in order to justify their actions to others. And this really opened up cans of worms.
If we are truthful about our intentions and goals, our innate intelligence can evaluate if certain actions generate certain results that meet our intended goals. If we are not getting the desired results, we can then objectively determine whether there’s something wrong with our actions or goals. Now, imagine these people with their desires/intentions so well hidden from everyone including themselves that this process can no longer happen. I have observed how such people have acted time and again, in ways that is not giving them or others any benefits (but only pain) yet they persist in their harmful behaviour. One example of this behaviour can be seen when Mara tried to disguise its intentions to the Buddha. Such beings, whether humans or not, have lost this innate ability to self-correct which is so sad.
These, I think, are pitfalls with identity view. Feelings of superiority or inferiority, to the point of harming ourselves and others, can happen to anyone at anytime in their lives. Freedom from these dangers can only happen at the state of Arahantship as Venerable Sariputta alluded when he says he do not despise himself. Similarly, Ajahn Chah when questioned on being afraid of very diligent disciples, said, “If we think others are worse or better or the same as us, we go off the curve. If we discriminate, we will only suffer.”
I don’t 100% grok Ajahn Chah’s words but I suspect it is a bit like concentrating in a tennis game. Rather than judging yourself, your opponent and others, you are just with the racket and ball. Giving your all and enjoying the moment, playing for each point regardless of how well or bad you played. In the case of Arhants, they don't need to concentrate on not discriminating themselves or others, it's just effortless.