The claim that democracy has built nations is flawed. From the start, groups like women, the poor and people of colour were prevented from voting. These exclusions were central to the nature of these new states, suggesting that these groups had to be excluded if democracy was to work properly. Today these exclusions still persist in many ways; most notably through voter disenfranchisement.
Many nations that claim to draw legitimacy from the people in reality are not democracies. Modern dictatorships from Juan Peron in Argentina to the one-party states of China and Vietnam are often very nationalistic in their rhetoric and policies, but are not democracies.
It is also not clear that democracies can only function in nations. There is a long history of democracies in smaller communities like villages and cities which were arguably more democratic than national democracies.