If you're looking for a philosophical term for the belief or behaviour, egoism fits:
[Merriam-Webster]
1 a : a doctrine that individual self-interest is the actual motive of all conscious action
b : a doctrine that individual self-interest is the valid end of all actions
2 : excessive concern for oneself with or without exaggerated feelings of self-importance
In such beliefs or behaviour, if something doesn't concern the person directly, they care less about it.
Similarly, if they see somebody else as being like them, they may have more interest in how things affect the other person because it might have a similar affect on them. To an egoist, how the other person is affected would be taken as a kind of early warning system—similar to the canaries miners used to take into caves to see if they needed to worry about breathable air.
Note that in this case, empathy doesn't equate to sympathy, but merely practicality and intellectual interest.