Cave dwellings are a rather young phenomenon, although pop culture tells us something different. We speak of cavemen when we mean stone age people, although they certainly did not live in caves. The wrong impression became popular in the 19th century, because most archaeological finds were made in caves. This is only because their remains were best preserved in caves. Our ancestors were nomads and lived in tents. They loved to use warm, south-facing cave entrances. However, these are rather rare, and were therefore only sometimes visited. An archaeologist speaks of continuous use if a hunting group made a stop every 100 years. Unfortunately you cannot take caves and cave dwellings with you when you move on.
The essential step was the one from nomadic life to sedentary life. This also made it possible to build houses and use them for longer periods of time. This was also true for cave houses. Nevertheless, most cave houses are much younger, the early artificial caves usually had more important uses. Cave houses are either from the late Middle Ages or early modern times. The increase in population has always been accompanied by poverty and a lack of housing, and thus an increase in cave dwellings. This is especially true for industrialisation, which generated a poor labour force. Therefore cave dwellings were more like slums than dream villas. At the end of the 19th century, they were "sanitized" by martial means, partly by the forced relocation of the entire population.
Houses are difficult to build, we need appropriate material and certain tools for it. The digging of caves is often a bit easier. You only need something to dig with, depending on the softness of the rock, a wooden stick might be enough.
There are many types of rocks all around the world allowing artificial caves. Very good is volcanic ash or tufa. Formed in huge layers during eruptions, the lava had such a big content of gas and liquids, that it nearly exploded, once it arrived at the surface. Fine pieces of lava, or lava with small but numerous pores was formed. The resulting rocks are soft, and it is possible to cut caves into them.
A third typical rock for cave houses is sandstone. This is a sedimentary rock, sand produced by erosion and transported by wind or water, formed on the continent. The sand is lithified by the groundwater, water flowing slowly through the pores between the sand and transporting dissolved minerals. Typically, calcite or quartz are accumulated in those pores glueing the sand into a hard rock. If the lithification was not completed, the cement is too weak, or it is removed by erosion, some sandstones become soft and are suitable for artificial caves too.
Of course, modern machines allow the construction of tunnels in any material and very efficiently. The construction of cave houses is still very useful in areas with suitable rock formations. And it is extremely useful in hot arid areas, where the temperature underground is rather pleasant. A good example for such modern cave houses are the so called dug-outs at Coober Pedy in Australia. Probably there are more cave houses today as ever before in history.