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
Were you aware that mass production is also known as flow production or continuous production and is the production of large amounts of standardized products, including and especially on assembly lines.