Large airlines have standing, negotiated contracts with major airports to buy fuel (and almost always also other services like cleaning, catering, etc). Some times these are fixed-price contracts, sometimes they float in relationship to the spot price of jet fuel, sometimes they are a hybrid. You can think of these as any other complex financial relationships: almost any way you can imagine a contract to be drawn up, someone has likely tried it.
Airlines' operations desks also constantly monitor the price of fuel at different airports and different times - and in some cases airplanes carry enough fuel to make a return trip without refueling because it ends up being cheaper to carry the fuel rather than purchase it at the next stop.
For general aviation, the airport FBO (fixed base operation) generally has one and sometimes multiple fuel vendors on-site, that generally sell at a fixed price -- very much like a gas station for cars. Obviously, airports that have more than one fuel vendor generally have more competitive prices, but even for single-vendor operations they can't make the fuel costs TOO high, or pilots will purchase just enough fuel to take off and go somewhere that gas is cheaper.