An Underground City is probably exactly what you think first: it is a series of underground structures which form a city. While a single place for living is a Cave House an underground city requires much more:
This is - by the way - not a real definition. This term is not a scientific term, its just descriptive term used for classification. In other words, this page is describing how this term is used on showcaves.com and nothing more. Nevertheless if you look at the respective Wikipedia page you will see that the definition there is quite identical. There are discussions how to exactly define the term. We include the following three types of underground structures.
During history man built underground cities for reasons like defensive refuge or protection from climatic influences. Or simply because hollowing out soft rock ist sometimes easier than erecting a building.
Nice examples for this are the underground cities in Cappadolia, where early Christians lived underground because they were persecuted for their religion by non-Christian neighbours. Or underground cities on the Krim peninsula, which were built underground to hide from the frequent raids of the neighbours. Or they used underground structures which already existed, normally because of mining activities.
Even today there are good reasons to build underground. Normally it's not persecution or frequent raids, as we handle that with open or not so open wars. Mostly it's a result of an extreme lack of space in modern cities or to avoid the nasty climate.
A fine example for the climate thing are the undergrond cities in Canada, most famous is probably PATH in Toronto or the ville souterraine in Montreal. Others are found in Finland, Russia, and other northern countries where the temperature, ice, and snow in winter are an issue. The same with high temperatures can be found in Australia, Spain, and Iran.
And of course there is the main reason for anything: money! A lot of those cities developed because many people used the subway to get into the city, someone opened a shop which was frequented by commuters and flourished. The result are underground shopping malls of enormous size, which may even connect two or more subway stations. So if you are done with shopping you just look for the next station to get home...
This are underground cities, which never worked as an underground city. You could say this are above ground cities which went underground, normally after they were abandoned, or they were abandoned after they went underground. Sounds strange, but this category is actually quite common, much more frequent than you might guess. The point is, that in former times new cities were built on top of the old cities, mostly because there was no machinery to remove the debris. So if a city was destroyed quite massively by an earthquake, a fire, a flood or something else, it was sometimes abandoned, the floor raised, and the new city built on top.