The catacombs were built primarily as an underground solution to the problem of overcrowded cemeteries in urban areas. As cities grew, the need for burial space increased, leading to the construction of these subterranean networks to safely store and protect human remains while also addressing public health concerns.