@mostmodest
I'm assuming you haven't played any of the X series yet. (X beyond the frontier, X3 Terran Conflict, etc.)
But basically if a station is low on something it wants, it offers a high price. (Implies there is low supply, so they pay a premium for resources)
If already has lots of stock of something it buys, then it offers a low price. (Implies there is high supply, so they aren't worried about getting more)
Similar for selling, if a station has little of something it sells, then it asks a lot for it. (Implies there is high demand, so they cash in)
If a station has lots of something it sells, then it asks a little for it. (Implies there is little demand, so it tries to get people to buy by making it cheap)
Systems typically focus on producing a single product, so overall you have a good change of getting that product for cheap in that system.
For example, if a system has ten smelters that turn asteroid ore into metals, then the demand there for asteroid ore will be high (all ten of the smelters want some).
And metal will be cheap (ten smelters all producing metal will mean lots of metal for sale).
Distance from supplier naturally makes the price of something go up, since it is likely the transports will fall to pirates, or the merchants will simply sell to somewhere closer.
I mean, if I have to travel ten sectors to sell for only 1 credit more, then I won't bother.
But if ten sectors away a buyer offers 10,000 credits more... well.