Subterranean factories are a special sort of bunkers. During World War II many important factories were built inside caves or artificial caverns.
But some kinds of factories were built into caves and tunnels much earlier. Caves are cool and have a high humidity, which is useful for many products. Especially food stays fresh much longer in the coolness of a cave. So in times before the invention of refrigerators, caves were sometimes used to produce canned food.
On the other hand the cool temperature was not very comfortable for the workers. In times of peace this was compensated with higher wages, so the benefit of the caves hat to outdo the higher costs. And the higher corrosion of the installations increased costs even more. In war, of course, this was not really relevant. So its easy to undestand, that by most subterranean factories are war time factories.
Cool caves are not only usefull to produce food, but also for the storage of food, like wine, bear, and vegetables. But this is another story...