The price is set based on the competitive market forces for travel between A and C. Each airline provides that service through a different hub city, B but fares to/from B are irrelevant to the market conditions for A to C travel. If each airline wants to compete on A to C travel then they have to set their fares based on the market rate for A to C regardless of which hub they use to connect those passengers.
Airlines aren't selling airplane rides were a longer ride is more expensive than a shorter ride. Like most businesses, it is not a cost plus profit calculation. In markets where the supply/demand ratio allows higher fares they charge more, in markets with more supply vs demand they charge less. None of that has anything to do with the supply/demand situation for flights to or from their hubs.