A friend of mine said something to me, that we tend to project "from our shadow" (inner, childhood traumas) when we react to something threatening to ourselves.

But I also noticed that, when you add value to a relationship or an interaction, when you become invested, you tend to project onto the other person that he/she is like this or like that, but because you are like this or like that.

Why? And how to fix? Or is it a "bugged functionality" that needs improvement?