Assuming it was somehow natural or accepted for humans to favor certain humans over others, it would be the is-ought gap fallacy to argue that this is therefore moral behavior. Such ethical problems are considered in variants of the trolley problem, or the lifeboat dilemma https://en.m.wikipedia.org/wiki/Lifeboat_ethics or similar issues around triaging a group of patients where only a limited number can be saved. Ethically it is not allowed to restrict or extend the rights of people based on gender, race, age, religion, and so on. It is also illegal in many countries for organizations of the state to explicitly discriminate that way. Typically it is viable to triage in such a way to maximize something like the number of people saved, or eliminate wasted efforts. However, nations and organizations can to some degree still act that way when preferring to help some nationals more than other nationals in trade contracts, cooperations or economic aids. This is still immoral, but much harder to decide, control and fix. However in psychology it is known that humans feel stronger bonds to people with whom they share some properties, and so we "understand" if people make such choices to some degree, even if it remains immoral or illegal. Philosophically there are no reasons why such psychological tendencies should impact moral judgement.