This was an example sentence in Practical Chinese Reader 31. Do people actually live in factories, or is there some cultural context I'm missing? In previous chapters, people are constantly visiting factories《参观工厂》, which I found bizarre. Who would want to visit a factory? Why would they live there?
Yes, it is common for many Asia countries that "lodging" (typically dormitories) is provided by the companies and often these "factories" form cities on their own.
A famous (or maybe better to say notorious) example is Foxconn. From Wikipedia:
Foxconn's largest factory worldwide is in Longhua, Shenzhen, where hundreds of thousands of workers (varying counts include 230,000, 300,000, and 450,000) are employed at the Longhua Science & Technology Park, a walled campus sometimes referred to as "Foxconn City" or "iPod City". Covering about 1.16 square miles (3 square km), it includes 15 factories, worker dormitories, a swimming pool, a fire brigade, its own television network (Foxconn TV), and a city centre with a grocery store, bank, restaurants, bookstore, and hospital. While some workers live in surrounding towns and villages, others live and work inside the complex; a quarter of the employees live in the dormitories, and many of them work up to 12 hours a day for 6 days each week. Another of Foxconn's factory "cities" is Zhengzhou Technology Park in Zhengzhou, Henan province, where it is reported 120,000 employees work.
Many people live at factories in China because many of them are migrants and it's more economical from their point of view to live in factory dormitories. It's also more efficient for them and their employers to have them on-site. Remember, China is crowded, housing is expensive and commuting is a bear. As for who would want to visit a factory, well many people, including vendors who sell parts, materials, and equipment to factories and customers who buy from factories.