Napoleon, the Corsican, played heavily on French nationalism; Stalin the Georgian, ended up doing the same with Russian nationalism; Hitler, the Austrian, played on the dreams of German nationalism. Can we say that nationalism is pliable and manipulable? This is a theme of Benedict Anderson's Imagined Communities. Similar ground is covered by Joseph Henrich in his The Secret of Our Success.
I had previously cited the Yuval Harari book which makes the point that we humans dominate the planet because of our great success forming and working in teams. He cites our tendency to create the stories ("imagined orders") that form the basis for teams. Most of us become fans of various sports teams. Many others are attracted to the team aspect of politics. Still others revel in nationalism(s) or even strong regional alliances.
Nationalisms form around language groups. The ability to learn from each other is the key -- and common language makes that possible. But how did we get language? This fundamental ability is Henrich's favorite theme: Our cumulative (and continuing) culture-gene co-evolution. [This is quite complex and makes the book well worth reading.] The way best to use the language is infused with social norms: facial and other bodily expressions add a great deal; face-to-face meetings are still important. Add social norms and their reputational consequences.
We get to form "larger collective brains" (Henrich, p. 227). Stories as to how and why cities are "Our Greatest Invention", (E. Glaeser) are the obvious elaboration. These days, we communicate via many channels, including the occasional face-to-face meetings. Cities will spread out but there will always be agglomerations.