I find it fascinating looking at history and seeing either the success or failure of countries made up of various peoples. Politics come and go, but ethnic identities stick around much longer. I wonder,what makes certain nations either better or doomed when their makeup is diverse?
There seem to be some good examples of this. I'm sure the comparisons I make below are not the best. Please let me know if you have better suggestions! However there are some places where different ethnicities and nationalities exist together in relatively stability and general harmony. There are also certain places that do not have any long lasting pan-nationality.
Some good examples of Stick-togethers are;
Some good examples of break-ups are;
Some exceptions to everything
I can't speak to many of the examples you listed, but Nepal did so through a mixture of military power and cultural imposition. Modern Nepal (since the mid-1700s) resulted from the conquests of the Gorkha king, Prithvi Naryan Shah. After decades of campaigns, he composed a treatise on political rule called the Dibya Upadesh. The most commonly quoted part of is "Nepal is like a yam between two boulders" (referring to India and China). This quote obviously lends perspective whenever the geopolitical situation of Nepal comes up.
However, the treatise is more than just Shah's take on geopolitics. It's also laden with religious overtones. This is no coincidence, because Shah legitimized his rule over this new empire by appeal to Hindu traditions. Describing his military victories, he is quick to describe how others praised his piety ("You, O Prince, have held at all times great respect for the cows, Brahmins, guests, holy men, gods, and goddesses... You will one day be king of Nepal"). Nepal was to be governed by a pure Hindu kingship, and identity was to be based upon the cultural norms of the Hindu hill castes (often abbreviated today as CHHE--'caste hill Hindu elite').
This continued with some success for several decades, but was truly implemented in force after the Rana takeover of the mid-1800s. In 1846, Jang Bahadur Rana killed off many of his rivals in the "Kot Massacre" and thereafter began a hereditary prime ministership, with the Shah kings kept on as titular figureheads but with no real power. The Rana regime then implented the Muluki Ain, a legal code that formally established a national language (Nepali), national dress, and perhaps most importantly, included all ethnic groups (Hindu or not) into a national caste hierarchy system. Everything from employment, property ownership, and punishment for crimes was based on what legal caste one found oneself in. The power of the Muluki Ain was augmented with new infrastructure--chiefly roads--and the printing press. The government was able to expand its reach to formerly isolated communities, and control the language of political power (I'm not using cheeky metaphors here, the Nepali language was that of official business, education, politics, and whatever else the regime could impress it upon).
The Ranas came to an end shortly after the British withdrew from India (British patronage being a key element in their rule), and Nepal experience 10 years or so of a democratic opening. Even here, the major political parties were headed by the CHHE's. Contesting authoritarian political power was still an activity for the elites. The King staged a bit of a coup in the early 1960s, and thereafter implemented the Panchayat system. This was a 'partyless' political system where the King was able to exert extensive control while still claiming that 'democracy' was occurring. Again, minority ethnic groups were still largely excluded from positions of power and influence. The 1990s saw a people's movement led by the descendants (metaphorically and in some cases literally) of the democratizers of the 1950s. So again, in the perspectives of many minority groups, the CHHE's were defining what it meant to be Nepalese and how Nepal was to be run. A civil war soon broke out, and that's where the 20 year rule cuts us off.
So the take home is: a combination of cultural/legal impositions and the military/police power to back it up created a single country out of multiple ethnic groups.
If you want a more in-depth take on the legal aspects here, and how they were informed in part by Western traditions, I'd recommend the following: Mara Malagodi, "Forging the Nepali Nation through Law: A Reflection on the Use of Western Legal Tools in a Himalayan Kingdom," Studies in Ethnicity and Nationalism, Vol. 8 No. 3, 2008.
Also, Prithvy Naryan Shah's "Dibya Upadesh" is a quick, fascinating read. L.F. Stiller, S.J., has a translation of it that can be found cheaply on Amazon, or else most public and university libraries seem to have scanned in e-copies available.