The modern idea of the "nation state" arose throughout Europe in the nineteenth century. While this occurred in part as a result of a growing sense of a shared "national identity," the primary drivers were political and economic. Indeed, the solidification of nation states often occurred despite vast cultural difference.
Two examples stand out: Germany and Italy, nations that did not exist before the nineteenth century. Yes, there had been a sense of a "German identity" for decades, but it was dispersed throughout the erstwhile Holy Roman Empire. Germany, like most European countries, was an imperial power. The creation of that German nation state was expeditious in advancing Germany's imperial and colonial goals. It was also created in response to the increasing number of military alliances that formed in Europe in the nineteenth century.
Italy was a collection of disparate provinces and kingdoms. Its unification was a result of the necessity of forming military alliances during the Franco-Prussian War.
Interestingly, across the Atlantic in the United States, President Lincoln, through his use of military force, once and for all settled the question of federal primacy in the Civil War. Thereby, he solidified the endurance of the American nation state, despite the "ununified" cultures of the north and south.