Preface: This is a very abstract question since it really would depend on the worldbuilder, and the type of setting they are trying to build.
In Established Works
In works such as Lord of the Rings, kingdoms, or at least cities are mostly separated by race.
In the real world, "kingdoms", or rather, countries, are separated by language primarily (with some very fuzzy lines), as well as just overall history, but definitely not by "race", at least not primarily, and not as a constant rule.
In works such as A Song of Ice and Fire, "kingdoms" are split primarily by alliances and geographical landmarks (The Narrow Sea, The Wall, etc). Since "races" aren't very prominent, and even where they are (Such as humans and giants beyond the wall), they coexist just fine.
In D&D it seems that all of the main/original races are pretty common in all parts of the world. Even in places such as Mithral Hall, while dominated by Dwarves, Humans make up 4% of the population. Other cities, such as Waterdeep, the population is even more diluted. These are just cities though (even if they have their own high level form of government), if we look at the overarching kingdoms, rather than just cities, the races begin to blend even more. While it seems that mountains are mostly inhabited by Dwarves, and forests by Elves, Faerun is mostly diluted like the world out here is.
From the worlds above, it seems that some abstract rules that they set are as such:
- Borders are set by conquest and alliances.
- Some fantasy races may choose (or are forced) to live in a certain environment, but wouldn't necessarily create a kingdom/country around that setting.
- Language and culture may be a primary reason of divides, but with conquest and time, language and culture can change.
So what did I get wrong? What have I missed? Are there other important rules to take into account that you can think of when building a fantasy society? What are some obscure (or common) events that may break some or all of the outlined rules?
Bonus: What effects might magic have on any of these rules? (This might warrant its own question, depending on the magic system)
EDIT: You're all correct in saying that establishing a kingdom is simple, it is a king ruling over a place. The question was supposed to invoke a discussion, not literally about the logistics of creating a kingdom, but how fantasy aspects would influence the emergence of kingdoms in all aspects; literally, geographically, historically, etc. But it should also call forth a question of society and how multiple races would coexist, and how they would come together to create countries/kingdoms. Was Toliken more correct by separating these races into their own kingdoms, or would it be more believable/realistic to have these races and societies mingle a lot more than that like in the world of Faerun of D&D?