Your view seems to be that some communities are allowed to prevent outsiders from working in the jurisdiction of those communities in order to accrue modest economic advantages for community members. It seems like communities that share local resources and markets do have this property and communities that share skin pigmentation do not.
Why?
Typically people belong to multiple communities, say family, city, state, world. What kinds of actions are permissible in order to secure modest economic advantages to each of the these communities? What if there is a dispute between the various jurisdictions. What if the "world community" votes overwhelmingly in favor of open borders? What if a NYC block (which is certainly a community that shares local resources and markets) votes to ban black people from living/working there? Why is this wrong but the American community banning Indians from working in America not?
Not at all. Because being born with skin pigmentation is not the same as building a community together, that shares local resources and markets.