Every game I've played that is of this type, Warehouse / Barn management is the core skill in being able to do things and not become frustrated by the constant "Warehouse / Barn is Full" messages.
Since the products created in the factories are all of a "fixed quantity" (40 Nails, 30 Iron Powder, etc), you need to make sure there's enough "bulk space" to be able to empty the factory slot. Two things help, 1) use the output conveyor (initially 2 slots) to hold items rather than put them in the warehouse. Those two shelves can be thought of as "extra warehouse space". And 2) if you need to make some stuff and the output conveyor is full, put it on the "input conveyor" before removing an item from the output conveyor. Putting stuff "in" makes room for taking stuff 'out".
Also, it is tempting to use your largest train to fetch raw material. Often this is more than you need for the task at hand. For example, if you need 30 units of Iron Ore, use the train that gets you closest to that, don't fetch 45 if you can avoid it. The unused remainder takes up warehouse space.
FInally, don't be afraid to delete / dump any easily obtained raw material to make room for a factory item. Coal, Iron Ore are replenished quickly, others like Wood or Copper Ore only take 5 minutes to replenish.
And lastly, this game requires some patience, don't waste your gems to speed up things., you'll need them later. There are lots of "Watch and Ad to Speed Up" opportunities (Blue Button with a Play Icon), use those instead.