The nomads of the pre-Agricultural world didn't walk around like Settlers in a game of Civ5, just looking for a nice place to sit down and go "Aha! I will build Damascus here!" The invention of agriculture essentially made it viable for people to, instead of moving around looking for food, settle down and amass in one place. This is because the advent of farming made it easier to produce more food than was strictly necessary for survival. This meant everyone had enough to eat, more people would settle down or make more babies, they would grow and make more food, and the cycle continues (not to mention that if you have more grain than you need, you can start feeding and possibly breeding animals as well). Then you have more complexity arising as a result of that, such as writing and mathematics (because when managing these things, it becomes helpful to be able to understand and easily convey what's going on over long distances), and eventually city states.
However, the real point of your question seems be imply that places like Egypt and the Middle East are just horrible sandy places that are really bad for building cities in. And by and large they are, if you're actually in the desert. But those areas have huge rivers running through them such as the Nile in Egypt and the Tigris/Euphrates in the Middle East. There's enough natural irrigation, both consistent and seasonal, that it forms what's generally referred to as the "Fertile Crescent", which looks like this.
As you can see, there's a crescent shaped fertile area that runs along the rivers in the Middle East/Egypt that corresponds to the places where the first civilisations began appearing.
One you crack a few key problems, such as how to store grain, efficient farming (for example: manipulating rivers and flood plains), and achieve a critical mass of people to get everything done, you essentially have the beginnings of a city on your hands. After all, cities are just large towns, and large towns began as small villages. Once you have a large city, you can begin exerting influence with military force or coercion, and you start having a sphere of influence. This maps pretty well to our general broad understanding of what a "country" or "state" is.
tl;dr: Egypt and the Middle East gave rise to some of the earliest civilisations because, contrary to popular belief, they contained some excellent places for such things to occur.