The better a place to live your country is, the more people would want to live there. And since it's a country, it will try to keep as many of them out as possible.
That seems like flawed logic to me. You cannot make a single country a better place to live without making the rest of the world less so. It is still a self- and community-centric view on the world.
The way I always saw Nationalism vs Patriotism was that the first one allowes virtually no criticism while the later it is encounraged to critic and demand things from your country because you want it to be a better place to live
Many people needs someone tells them to do. In Egypt it was alien gods, cult leader, later church, mid century mustache guts nor Donnie and fake news. I and few other can thing by my self.