Have you ever worked in a factory?
I have not but factories became about with the introduction of machinery during the Industrial Revolution when the capital and space requirements became too great for cottage industry or workshops.
Yeah, they definitely are a modern invention.  The population also used to be much smaller.  More people = needs for mass production
Mass production
Mass production, also known as flow production or continuous production, is the production of large amounts of standardized products, including and especially on assembly lines. Together with job production and batch production, it is one of the three main production methods.
The term "mass production" was popularized by a 1926 article in the "Encyclopædia Britannica" supplement that was written based on correspondence with Ford Motor Company. The "New York Times" used the term in the title of an article that appeared before publication
Factory
A factory, manufacturing plant or a production plant is an industrial site, usually consisting of buildings and machinery, or more commonly a complex having several buildings, where workers manufacture goods or operate machines processing one product into another.
Factories arose with the introduction of machinery during the Industrial Revolution when the capital and space requirements became too great for cottage industry or workshops. Early factories that contained small amounts of machinery, such as one or two spinning mules, and fewer than a dozen workers have been called "glorified