As I understand it they are governed by the star systems economy. Different star systems produce different types of goods. There are seven types of economy and every star system has one.
If you have an Economy scanner built into your ship you can see the economy type and prosperity from the Galaxy Map.
Items which are in high demand in the star system will be purchased from players at a higher price and be marked with a green
+Example% showing how much the market will pay over the regular price, and obviously the red
-Example% if the item is abundant.
Knowing this leads you to wanting to setup Trade Routes between star systems which produce goods which are in demand in nearby star systems.
As mentioned on the wiki
Resources replenish slowly and the fulfilled demand at a target lowers
the price for consecutive sales
So it's worth noting that if you sell more items, the price you get will decline.
The wiki also notes that it's worth having more than one trade route available to allow demand to recover.
An easy bridge to remember the two trade routes are the terms ITEM and
CAR. Industrial-Technological-Energy-Mine and
These are the star system economies you'd want to visit in turn to maximise your profits.