These prices are raw data extracted from
item_kinds1.txt using the M&B Item Editor. In practise, merchants will normally charge more for goods they sell and pay less for those they buy. Putting points in Trade will bring these amounts closer to the item's true value.
Merchants pay different amounts for goods depending on how rare it is in their city, so selling to places where it is the rarest will yield the most profit; see Trade for more information.
There is also a supply/demand system in play: buying multiple identical items simultaneously will gradually increase the cost of additional units, and selling multiple identical items at the same time will gradually decrease how much you are paid for them.
If you have food in your inventory your party will gradually consume it, lowering the number of units each item contains and the value of the item itself. Generally speaking your party eats items at the top of the inventory first, so placing a few items you don't care about at the very top will help keep your men from eating what you're going to sell. Every 14 hours, one unit of food is consumed for every three troops in your party.