If you give any thought at all to mapping your world, you will hesitate before deciding where to place towns and cities. It would be best if some logic were involved - but it is hard to envision the problem from your present viewpoint as GOD. Instead, you need to imagine that you're just an ordinary person.
Towns are built by all sorts of people. Some are built collectively - a group of settlers appear at the same time and within a few weeks a small town exists. Other towns begin with just one house; another person comes along and builds a second house nearby, then a third and so on until the collection of houses makes a town. Still others begin as a resource is discovered and random people converge to grab as much as they can. Towns even emerge by Royal Decree, where soldiers appear to produce a military town or naval port out of nothing.
These methods all have one thing in common - they serve a need, one that exists before the town. This is very important and must be understood wholly. Towns do not create needs - though it will often seem that way. At the heart of every town's founding - and in its growth - is a need being served and expanded.
Consider the one house in the example above. Let us say that you are alone. You have no family, no ties, no political motives, no plan except to live apart from other people. Where is it you build your initial shack?
Well, you will need food and water. Most particularly water. Food tends to be either on the hoof and moving about, or growing near water, so it will be most convenient if you are near enough to water that the journey you take each day to get it is minimal. That need exists already. The house is build to service that need.
If another comes to build a house nearby, it must be that the same water source is sufficient to serve more than your needs. If that water source is rare while the potential for food in the locality is high, more and more people who need food and water will arrive to exploit it. The town, if it evolves, will arise to organize the distribution of food and water, to keep the locals from harming one another and ultimately to enable transportation of outside goods inwards in exchange for local surplus.
The town itself does not create this surplus. Neither do the people. While they do the work, the surplus is inherent in the location, whether or not a town ever existed. The town succeeds because the surplus is possible, inducing people to arrive and work it.
When more people arrive, seeking more than the surplus can provide, we get unemployed labour and beggars - who in turn do their best to sell whatever they have that can be devised, leading to vice. Vice is merely the result of people without traditional resources or skills taking advantage of a population to sell (or make money upon) what does not require traditional resources or skills: prostitution, theft, murder, forgery, fencing and so on. Vice is only possible when the population itself becomes a resource that can be exploited through corruption, immorality and trespass.
Whether you are alone or in the company of other settlers (or a monarch deciding where a city ought to exist for the good of the kingdom), you are compelled to make certain judgements about the exact placement of any settlement, from a house on up. These are judgements regarding the settlement's defense, practicality, resources (as we've already discussed), accessibility and its protection from the elements. Choose wrong and while the town may emerge for a time, eventually it will be abandoned or washed away by nature. Town histories are filled with tales of towns that were moved across the river or five miles further up the road, devastation by invaders, fires, depletion of resources and so on. When a devastated town retains a good location, it is rebuilt. When a devastated town was badly placed, the former citizens give up on it.
Some towns thrive for centuries before failing. Sijilmasa, in modern Morocco, was arguably the wealthiest city in West Africa a thousand years ago. Located on the edge of the Sahara, it was admirably suited for caravans departing from gold-rich Mali, Guinea, Ghana and Bornu, the perfect transshipment point from camels to donkeys before transport over the high and dangerous Atlas Mountains (camels do not like mountains). As a result, the city grew huge - but by the mid 16th century, without much notice or fanfare, the population evaporated. As wikipedia says, "The ruins of the town lie for five miles along the River Ziz."
What happened with the beginning of the 15th century, circa 1415 forward? Portugal happened. Specifically, John I.
Imagine what that must have been like as the 15th century waxed and Sijilmasa waned. Year by year, less camel trains arrived from Mauritania and Mali. With the founding of Arguin on the Mauritanian coast, in 1445, began a series of forts that would eventually bury extensive trade through the deserts of West Africa. Family by family departed Sijilmasa . . . until at last the city was gone.
When I begin again, I'm going to talk about specific types of cities, why they're founded and what happens when they're successful. It's a large task, as I count 22 specific town forms in my bucket. For each, I will give examples from the real world. I hope this will help expand the idea of what functions a town performs and how you should better understand the story behind the towns in your world.