The economic theory of capitalism has, as one of its basic aspects, the idea of supply and demand. This blog may be "old news" to many -- but not to others.
The amount of product (supply) at a given price tries to reach a balance of demand and willingness/ability to pay. Under many conditions, this works as a self-maintaining mechanism. There are quite a few cases -- sometimes called "edge conditions" -- in which it does not work well. These cases include newly introduced products, pandemics, shortages, monopolies/cartels, and other cases where the balance gets thrown off rapidly.
No company wants to sell a product below the cost needed to manufacture and provide. However, there are cases where this may be to their advantage. One is when demand has gone down so much (temporarily or permanently) that they have the cost of storing a large amount of inventory from which they don't expect a profitable return on investment. Another is as a "loss leader" -- making the price attractive to attract potential buyers of other, higher profit, items (often done by grocery stores). The final one mentioned here is that of forcing the competition to quit. A company with "deep pockets" (money available in reserve) can force their competitors to stop making competitive products. Usually this is legal but will often leave widespread bad feelings.
Newly introduced products will require development, marketing, and promotion. The creator of the products hopes that these costs will be covered by eventual sales. But, at the beginning, they will likely need to sell below cost while building a market. When Honda introduced the higher-end Acura line, they priced the cars very close to that of their Honda line -- increasing the price as the brand-name recognition developed.
Pandemics are special cases where both shortages and surplus can exist -- even at the same time. When most people stopped driving and stayed at home, the need for gasoline plummeted and the price of gas went down (not to the same extent). But fewer trucks on the road, and ships and trains moving product, and fewer people to staff the fields and factories can (and did) lead to shortages.
Shortages indicate less supply than potential demand. In addition to pandemics, it can be part of a situation where production is reduced on purpose (oil, for example), because of disease (bird diseases causing reduction in chicken numbers), because of environmental problems (droughts, floods, unexpected hot or cold temperatures, ...), and deliberate reduction in cases where there is little competition (arson of facilities and other methods). There is usually no inherent requirement to raise prices when supplies are not enough to meet the demand. But, with only some product available to a larger set of potential consumers, how is the final market determined? By lottery (this does happen for certain products -- like the PS5, for example)?
More often, the company increases the price. The higher the price, the fewer people want/are able to buy the product. At some price, those willing and able equal the amount of product. Record profits can be made and the supply and demand balance. For optional products, this works well. For required items (such as food), lower income people are greatly penalized. Note that, for longterm production shortages, it is expected that other companies will start manufacturing (not true if it is caused by limited resources) and the competition will force prices back down as the supply increases.
Monopolies and cartels allow companies to control the supply and price directly while eliminating (through agreements, buyouts, or less legal methods) competitive pressures. In the US, many laws were enacted following the Great Depression hoping to bring such under control. A desire to increase or decrease such laws and the proactivity of enforcement of such laws depends upon current political vision. Other than those laws, business practices and prices are (in the US) controlled solely by the companies.
In theory, the number of products at a particular price will (eventually) balance against the number of people willing and able to purchase at that price. But there are many detours around theory.