"supply and demand" is correct, but like the "calories in-out" theory of weight loss, is missing a lot of important causality about the supply and about the demand. There are a LOT of textbooks that go much deeper - George Stigler and Milton Friedman are well-known authors on this topic.
What determines how much things cost? The textbook answer is, supply and demand. But that's just the Teacher's Password. An actually useful model could be used to answer some questions like "How much should I ask for this product?" or "Am I getting ripped off?".
We typically think of cost as monetary, and for most purchases this is the only sensible way to think about them. When I eat pizza at the restaurant or take a train to another city, in the end the question of how much it cost is rather simple. You want something, and to get it, you'll have to fork over some money. If you want the thing more than the money, you buy it.
Things get more complicated when comparing multiple options. Do I take a bus or a taxi? The bus is 30 minutes slower, but the taxi costs 20€ more. This pizza place has better reviews, but the other one is cheaper. The nice thing about money is that it's fungible, and we can measure utility in it. Sadly, it's hard to be consistent in such conversions, and the ability to do them can be harmful. Many of the conversions are probabilistic, which makes it even harder.
The most common conversion is time to money, as it's a subcomponent to almost every choice. If you treat minutes as fungible and elastic, you can use your hourly salary. This is not realistic, and marginal costs and benefits are usually not symmetric anyway. Another model is "aspirational hourly rate", where you use some arbitrary fixed rate instead. That might work a bit better, if you know how to select the numbers well.
An important step is to quality-adjust the time cost. Imagine a 10-hour overnight flight, 500€ in economy or 1500€ in business. Simplifying a bit, you'd be paying 100€/h for the upgrade to business. Or the other way around, you're paid 100€/h to pick economy instead. (I'm ignoring the progressive taxes here.) But this is a senario where you could realistically sleep or work in the business class, while in economy you'd be bored, re-watching the same movie for the third time. The real cost of business class is then more accurately 100€/h - salary/h + bored/h, and that might be worth it. Especially if you have a negative value for bored hours. I'm barely ever bored in an airplane, as noise-cancelling headphones and books exist. Still, the other factors like the physically painful lack of legroom, amplified value for the time at the destination, and the feeling of high status might make it worth it.
The quality-adjustment model can be expanded a bit more. You could say that watching a movie costs 15€ and two hours, but that would be nonsensical. It's the two hours you are paying for; just assign negative cost, and it all makes sense. Getting accurate estimate of the quality is super hard though, and even small errors accumulate over time. It's perfectly normal to, say, pay 10€ and 100 hours for a videogame, and only realize afterward that, in total, the hours were also an expense.
The pricing of mass-produced consumer products and services, with prices publicly available, looks quite a bit different from other kinds of trade. Most importantly, these are typically fungible, have known and consistent quality, and there's a lot of competition. I'm going to focus only on such things.
Intuitively, if you've not heard too much about supply and demand, you'd think that the most important component of the price of anything is the cost to produce it. For some products this is true: food in the grocery store or non-fancy restaurant is like this, as is renting an apartment, taking a taxi or any product with really low margins. Sometimes the grocery store might sell a single product at loss in hopes to bring in more customers, but the average still looks like this. And sometimes a ridesharing or food delivery service subsidizes prices for years in hopes to drive off competitors.
But sometimes pricing looks quite different. Bottled water at the airport costs quite a bit, yet it's essentially the same as from the tap. The rents are higher, too, and it's not rare for airports to charge a percentage of revenue too. The stores can effortlessly coordinate keeping prices at an equal level, and nobody seems to complain about cartels there.
Some other things are priced in waiting time, as mentioned above. Many people are willing to wait but not willing to pay. Time-based costs are most useful in domains where it would be outrageous to charge money, or at a loss the full cost. Government services, especially taxpayer-funded healthcare, are especially prone to this. Oftentimes demand is also reduced, when people are not willing to wait. The unfortunate thing is that the value is destroyed rather than transferred.