but in my mind those two things should be part of the same production line: Extract -> refine -> goodies.
This is a really common "it works like this in other games so it should work like this in Elite Dangerous" misconception. ED's economy is both more abstract and more circular than that. In other games the "endpoint" of the economy is things like ships or other non-market goods, which ultimately take out of the economy the inputs added to it by mining/farming/etc, whereas ED's economy doesn't
have an endpoint in that sense.
All of the big five production economies in Elite Dangerous (Extraction, Refinery, Industrial, High-Tech and Agriculture) produce at least some cargo that the other four consume. Most of the pairs have strong links in both directions (there is very little that Extraction and Refinery produce which Agricultural consumes, and very little that Refinery produces that Extraction consumes, but there's still at least one commodity going in those directions)
Extraction -> ores -> Refinery -> metals -> Industrial
is certainly a valid trade chain ... but so equally is
Industrial -> machinery -> Agricultural -> food -> Extraction
or
High-Tech -> technology -> Refinery -> biowaste -> Agricultural
Elite Dangerous economies as represented in-game are shown at "equilibrium" - NPC traffic is assumed to be bringing in some of their demanded cargo and taking away some of their surplus exports, to keep an overall equilibrium point (the exact position of this equilibrium point is then affected by BGS states, but that's not important here). Players can then temporarily move the economies away from equilibrium through their own trades.
So yes, a Refinery needs ores (and machinery, and food, and ...) to operate - and it's assumed that NPCs will be bringing in a baseline of those. The sources of those don't need to be in the same system - indeed, other than with colonisation, systems with heavily mixed economies are rare - the assumption is that the NPCs use their FSDs. If the player wants to improve production by bringing in needed commodities, this will if done enough trigger a Boom state, which tends to push the equilibrium export levels about 80% higher for a lot of commodities. It's not the "1t A + 1t B => 1t C" you might see in a game that's more about the spreadsheets and economy simulation and so on, but it works as a high-level abstraction.
If you mix an Extraction and Refinery economy on the same station, then a lot of the Extraction exports (and Explosives in the other direction) get plugged directly into the Refinery imports, so the market volumes of those on both import and export sides will fall. That's "good" from the point of view of the settlers in the station themselves - fewer external dependencies, less reliance on some very unreliable traders or exposure to pirate threats. From the point of view of us players, who get paid to create problems and then get paid again to fix them, a self-sufficient closed-loop economy is a terrible idea - it won't buy anything from you and it'll barely sell much either.
(This is how it's worked for the last decade, but this is also how no-one has needed to care is how it's worked for the last decade. Colonisation has had about the same impact as if they dropped the entire engineering/outfitting system in at once to players who'd spent the last decade
only able to use a limited range of fixed builds.)
Does one refinery only "eat" a certain amount of stuff produced by an extraction installation? If I build 4 extraction installations and 1 refinery, will both produce stuff to the market?
This is not a simple question to answer.
To avoid a boring "every refinery produces twice as much Gallium as it produces Copper" situation, all trade commodities have a range of possible production and consumption levels. The ranges are not the same for different commodities, and the production ranges and consumption ranges don't necessarily line up (which
can make sense, though they haven't been picked that precisely)
So if you add 4 Extraction exports and 1 Refinery, some commodities will definitely be exported, some will definitely be imported, and some will be in that grey area in the middle where it depends where your specific station falls in that range. Which you can't control. (It may depend in part on things like Wealth, Standard of Living, etc. but not in a way that you can do anything with)
If you want both Extraction and Refinery exports, the simple way to do it is to build one Refinery station and one separate Extraction station in such a way that they don't generate weak or strong links to each other. (Depending on where you're building them, this may be possible with them in the same system, or it may require you to put them in separate systems)
You can play around with some possible ranges of outcomes at
https://cdb.sotl.org.uk/specialisation/hybrid (I put this together for my own purposes, so you may well find it's a third-party tool you need a
fourth-party tool to get actual use out of)