What do we undestand by the word "state"? It probably involves such notions as: supreme authority within recognised frontiers; a claim on our obedience superior to any other claims (e.g. religion, family loyalty); a bureaucratic structure overseeing such things as defence, international trade, laws and judiciary, and from this does things to control our lives.
All this is quite a modern concept. It did not exist in mediaeval Europe, where real power was in the hands of the local nobility, and any control by central government depended the personality and competence of the King, without which things soon degenerated into anarchy. The modern concept of the state was developed in the Renaissance by writers such as Machiavelli, based on what they had read of Ancient Rome; and at the same time the development of a central bureacracy and a reduction of the power of the Church and of the feudal nobility made the growth of the modern state possible.
Even then, until the late 19th century the western European state, particularly in Britain, did not do much by today's standards. It did not build roads or railways, provide healthcare or schools, or regulate international trade. Few new laws were passed, and taxation was very low. Marx provided no vision whatsoever of what a state would actually do after the revolution: indeed, in one famous phrase, he predicted that it would "wither away"!
What is a "nation"? It is more of a concept than a plain reality; a self-consciousness, based on such things as a common culture, language, tradition and history; even belief in a single race. It helps if the area in question has obvious frontiers on most sides and a central government: e.g. England or France. National self-consciouness first developes towards the end of the Middle Ages, among educated people and intellectuals (e.g. Shakespeare) and only gradually spreads to the mass of the peasant population. It is doubtful whether most people in France were aware of being "French" in any meaningful way until the 19th century, and Russian peasants probably had no "national" feeling unil even later.
The nation-state is often seen as the only valid form of political organisation, as distict from (say) an empire, but it is a fairly recent idea historically. Furthermore, the two words carry different connotations: a little thought will suggest that the term "King of Scotland" is not quite the same as "King of Scots": the former implies rule over a define territory with frontiers, which may well contain people who do not consider themselves Scots: the latter implies a Scottish nation or race.
Problems of state versus nation began to emerge in Europe the 19th century. Italy had clear natural frontiers and a famous history, but there had been no single Italian state since Roman times. It was only unified in the 19th century. At the same time, German intellectuals developed a strong sense of "Germanness", but until unification in 1871 Germany had been just a patchwork of tiny inependent states with no effective central government. By contrast, the Empires of Austria, Russia and Turkey contained a great many different national groups, some of which had a proud historical past as independent states (Greece, Hungary, Poland), and others which did not. In the 19th century, scholars became interested in many of the latter: in their folklore, myths and peasant costumes, and for some of them wrote down their languages for the first time, using inappropriate or Roman or Russian aphabets (e.g. Finnish). This helped to form the first stirrings of national consciousness.
In central and eastern Europe there are few natural frontiers, and national dividing lines were therefore impossible to draw. German intellectuals were well aware that their concept of "Germanness" overlapped with territories inhabited by Czechs, Poles and others. Their answer was to decide that these cultures were "inferior" and need not be taken into account!
19th century Europe thus contained some states which were also nations (e.g. France), but others which were not. In the Ist World War the old Austrian and Turkish empires collapsed, and President Wilson decreed that frontiers should be redrawn in accordance with "self-determination": that is, nation-states. But this proved very difficult to apply, because, particularly when new states were established on the ruins of the old Austrian Empire, the new frontiers never coincided exactly with ethnic groupings, leading to much resentment and hostility. The newly-established nation state of Turkey expelled or killed large numbers of the Greek and Armenian minorities, but there remained a large Kurdish minority in the south-east.
Meanwhile, Lenin and Stalin managed to hold onto most of the old Tsarist Empire in the form of the avowedly multinational Soviet Union; but when this broke up in the 1990s, many new states were created, some of which had no tradition of statehood. The present war in Ukraine derives from the fact that Russia maintains that Ukraine has no national identity separate from Russia (the Ukrainian language being seen as no more than a reasant dialect).
The disintegration of Yugoslavia led to violence because it contained ethnic groups with a long tradition of mutual hostility (e.g. Serbs and Croats), but which now found themselves states with large ethnic minorities.