This is a cognitive bias. The tendency to overemphasize actions others take as attributed to their personality or “how they are” while ignoring or not giving enough weight to the context of a situation.
We see behaviors from others as their character, whereas if we commit the same behaviors, we don’t judge their weight as being attached to our character.
Give others the same leeway you give yourself.
I also feel a bit of comfort in knowing this, as it helps to not throw everyone into a bucket. If someone is rude you don’t have to be upset because you can Leaning into ignorance and assume better. Just don’t always bet on ignorance
A lot of defensiveness might come from the worry that others will use this “against” us. and not give us the same leeway that we ourselves use.
Toxic couples do this, they’ll keep the fantasy of their partner alive by not properly associating their actions with the version of their character they want to believe in. Negative behaviors get dismissed while positive behaviors get pedestal’d. The other partner may do the inverse to demonize their partner.