The short version is that we naturally identify with people similar to us. Geographic separation is an influencer in this. As such, a person will identify more closely with those around him than with those hundreds of miles away. An ingroup and an outgroup are thus formed. Per the article, such a distinction can then lead to either patriotic (pro-ingroup) or nationalist (anti-outgroup) behavior, depending on how strong one's ties to one's own group are.
This is why the only way to unify the planet as you suggest is to introduce an extraterrestrial threat strong enough to make our entire species an ingroup. Which is, if you'll forgive the comics nerd moment, exactly what Ozymandias does in the Watchmen.
>exactly what Ozymandias does in the Watchmen.
Although Dr Manhatten casts doubt on whether he achieves that goal for a longer period of time when he last talks to Ozymandias.
They follow across MANY borders, including a nation's. They follow family borders, neighborhood borders, city borders, county borders, state borders, nation borders and even wider cultural borders (e.g. US, UK and Australia closer to each other than to Peru or Brazil, and vice versa).
I think it's natural (as in "logical") to feel more attached to the place (and by extension country) nearest to you, as its the one you are more familiar with, you get to know it better (both its good and bad sides), and it gets to shape you far more than some remote place that it's just some abstract word to you.
"Brooklyn, place X" immediately evokes memories for a Brooklynite, of people, places, shops, relationships, buildings, restaurants, stages in their life etc. Copenhagen and Osaka, not so much.
It's also not "just because we were born there" -- it's because we grew up there, which is inherently tied to our lives and who we are, not some random momentary accident like "being born there" is meant to convey.
This probably breaks down for people (immigrants, etc.) that came to some place later in life, or to people who the place they live oppresses. Then again, even black slaves have loved the South as a place and a landscape, because it's the place they grew up, fell in love, walked, played, etc. Also tied with all the older persons in their lives they loved and who later died, etc.
There are also practical benefits besides the emotional bonds. If you don't love your place more than some abstract "Earth", you're less inclined to improve it, defend it, etc.
https://www.youtube.com/watch?v=-OnWnwwxNPA
Where he says "Pride should be reserved for something you achieve or obtain on your own, not something that happens by accident of birth."
Similar thing.
The same reason we take care of our own, but we don't go out of our way to help a stranger in need.
It's not that we consider them "less human" or that they actually count for "less" in abstract, but people do have (a) limited resources (so can't help everyone) (b) limited horizon of acquaintences and direct experiences (so can't know everyone) (c) preferences and alliances (so can't care for everyone).