The primary requirement to build a Factory is a rail connection to your Capital, which can be either a straight Rail Station/Railyard connection between the two settlements, or a combination of Railroad Station/Port to connect across bodies of water. The game, of course, makes it insanely difficult to tell exactly when you have a valid connection.
The biggest problem I have with the Civ VII system is that the Modern Age Tech Tree puts the Rail Station in the 2nd Tier of the tree, which is about right (first scheduled railroad service started in 1830 CE) but then puts the Factory in the 3rd Tier - the same tier with WWI aircraft and radio stations in it, when the first factories complete with steam power for their machinery showed up over a century earlier in the 1780s! Stationary steam engines to power factories of all kinds, in fact, should appear half a century before Railroads, not a tier later in conjunction with military equipment from over a century later.