I am thinking not just of Troy, that was repeatedly destroyed and repopulated, but also of cities of Mesopotamia that literally became hills, many Chinese of Egyptian capitals whose locations had to be guessed by archaeologists, and even Rome, which clearly was mainly fields in between ruins of bigger buildings in the Middle Ages, when its population was about 3 percent of the Ancient peak. How does this happen?
Edit: in particular, what did those cities look like at different stages of the process, say Ur just before and a hundred, and five hundred years after being abandoned, or Rome not long after the end of grain shipments and war population losses? Was it an endless stretch of empty buildings with a few inhabited ones in between? Could you just walk into a palace or mansion and say "okay, this will do for me"? Sorry about the typo in the title.
"He [Montaigne] fully believed that an ancient Roman, could one be brought back, would not be able to recognize [the city of Rome]. It has more than once happened that, after digging a long way down, the workmen have come to the top of some high column, which still remained standing on its base far beneath. The modern architects never think of looking for any other foundation for their houses than the tops of old buildings, the roofs of which ordinarily form the floors of modern cellars....There are many whole streets, that stand above the old ones, full thirty feet."
Montaigne may have exaggerated a bit about sixteenth-century builders sticking houses on top of Roman roofs. But it is undeniably true that ancient Rome was - and largely still is - buried by up to forty feet of deposited earth and debris. The progress of the burial can be seen on the facade of the Curia (Senate House) in the Roman Forum. Beside the original entrance are slots cut into the walls for medieval burials - at first only a few feet over the ancient pavement, and then a full eight or ten feet above it. By the eleventh century, the ancient (and modern) door had been filled, and a new one cut into the wall ten feet higher. This entrance served until the seventeenth century, when the progressive rise of the streets around forced the creation of another door, ten feet above the medieval one, on the level of the ancient clerestory windows.
How did Rome - or any ancient city - come to be buried so deep? If a city remains in use, rubbish thrown onto the streets and piled in alleys has a way of building up. Natural processes - windblown dust, the slow growth and decay of vegetation - also played a real but relatively modest part. If you look at a modern building that's been abandoned for a few decades, you can already see plants growing from every convenient crevice (take, for example, the roof of Detroit's famous Packard Plant). Early modern representations of Rome's ruins show similar rooftop forests. In a temperate climate like Rome's (or Detroit's), the soil produced by the lives and deaths of these urban jungles accretes slowly but steadily - under particularly favorable conditions, perhaps an inch every century.
Most ancient cities, however, are buried primarily by their own rubble. Take a conventional Roman apartment building, three or four stories high. The exterior walls of the first couple stories are likely to be brick-faced concrete. But the rest - the upper stories, roof, partitions, floors, etc. - is wood. Abandon the building, and let it decay. The wood rots fairly quickly; within a century, the floors and roof have collapsed inward, creating a waist-deep heap inside the masonry shell. Add another century or so, and the slow reducing action of rain and frost will pulverize the mortar of the masonry walls. An earthquake or two brings the walls down, and our erstwhile apartment building is soon a grass-grown mound, six or eight feet high.
There were, of course, more dramatic processes of burial. Sometimes, buildings were deliberately covered to make foundations for new structures; parts of Nero's Golden House were preserved this wall. (So, fifteen hundred miles away, were the famous church and synagogue of Dura-Europos, covered and conserved by an artificial siege rampart.) Floods - to which the Tiber was lamentably prone until the construction of the modern embankments - left deposits of silt. And occasionally, earthquake-induced landslides covered buildings like the Church of Santa Maria Antiqua in several stories of mud.
Every ancient city, of course, is different. Some are buried deeper than Rome: Sardis (now in western Turkey) is up to sixty feet deep, thanks to millennia of earth being washed down from its citadel. Cities in arid desert environments, by contrast, are often hardly buried at all: despite a millennium or more of abandonment, Syria's "dead cities" are still more or less at surface level - and very well-preserved. How deep a city is buried will depend on a whole host of factors, ranging from the local climate to the construction of the buildings to the later history of the site. Troy / Ilion, for example, was buried so deep largely because the site was reused more or less constantly for the better part of three millennia; every time an earthquake or sack devastated the settlement, the ruins were knocked flat and a new city rose on the rubble. Schliemann had to hack through forty feet of superimposed cityscapes to reach the Early Bronze age levels where he found his gold.
For the second part of your question, let's return - as I am always happy to do - to Rome. More particularly, let's watch the Roman Forum's transformation from monumental center to cow pasture. In late antiquity, the Forum looked much as it had during the mid-imperial era: a monumental plaza bounded by imposing basilicas and temples. By the early fifth century, the temples had ceased to be used for worship, though they were preserved from pillage by imperial decree and imperial respect for the monuments of the ancient capital. Alaric's sack of Rome (410) destroyed one of the great basilicas beside the Forum square (if you visit today, you can still see clumps of coins melted into the marble pavement). The building was never repaired, though its elaborate portico continued to house shops. From the early sixth century onward, small churches sprouted along the Forum's edge, and makeshift houses were built into some of the marble porticoes. Besides the old Curia- which had been converted into a church - the buildings around the Forum became increasingly decrepit and dangerous. By the year 800 or so, when the author of the Einsiedeln Itinerary passed through, the Forum was still recognizable, though surrounded by half-collapsed buildings. Two serious earthquakes in the early ninth century, however, seem to have brought down most of the tottering ruins, covering the old Forum square with a blanket of rubble. After this, there was no attempt to reestablish the Forum as a monumental space, and the Forum soon became the grass-grown field it would remain until the excavations of the nineteenth century.
As for settlement patterns, Rome's diminished medieval population is often said to have concentrated in ancient Campus Martius - i.e., the bend of the Tiber opposite the Vatican. This was certainly the area of heaviest settlement, but there were scattered pockets elsewhere, including a thriving neighborhood in the Colosseum itself. Many people apparently lived in the lower stories of the more solid apartment blocks; the Roman insula on the slopes of the Capitoline, for example, shows many layers of medieval re-use (including a small church in the top floor - note the bell tower). A few of the ancient mansions of the late antique aristocracy were apparently still inhabited through at least the ninth century (the Einsiedeln pilgrim mentions "palaces"). Others, like the house of Gregory the Great, survived as monasteries.
This post feels overlong, so let's summarize and be done: ancient cities are usually buried by their own rubble. How quickly and how deeply that rubble accumulates depends on the nature of the buildings and later reuse.
I go into more detail on early medieval Rome in this page on Rome's most impressive ninth-century church.
Your question touches on a key archaeological concept called site formation, which is crucial to how we interpret sites, and much of what geoarchaeologists study. This link provides a good brief overview of some of the theory behind site formation processes.
Wind (aeolian) or flood events (fluvial) are two common instances of natural sediment deposition which slowly accumulates on top of abandoned sites. The climate and geography of a given site are extremely important in how these processes influence deposition; many cave or rockshelter sites, for example, have very little deposition, and archaeologists must be extremely careful since, in some cases like these, excavating only a few centimeters could be looking back thousands of years!
On the other hand, using earth and rubble as fill to bury or level off unwanted portions of towns was also common. An 1862 site I studied in rural Minnesota was found nearly 1 meter (39 inches) below the surface; though historically a relatively recent site, over the past 160 or so years several landowners had used nearby sediment and debris to bury trash or level off the landscape.
As for the second part of your question, cities were typically abandoned slowly, often due to the threat of violence from nearby enemies or, more commonly, a lack of resources necessary to sustain it. Once a city fell or was abandoned, they were typically reused as extraction sites for building materials. Notable examples can be seen of Roman ruins reused in Medieval structures. Cities that are reduced to rubble through warfare or natural disasters are also more easily subjected to the site formation processes mentioned above.