Why could rental costs for apartments/houses rise while buying prices can go up and down?

I am from Australia, so my answer is based on my experience over here, however it should be similar for the USA.

Generally, what determines both the price of houses/apartments and the rents for them is supply and demand.

When there is high demand and low supply prices (or rents) generally go up. When there is low demand and high supply prices (or rents) usually go down.

What can sometimes happen when house prices go down, is that the demand can drop but so can supply. As the prices drop, developers will make less money on building new houses, so stop building new houses. Other developers can go bankrupt.

As less people (including investors) are buying houses, and more people (including investors) try to sell their existing houses, there will be more people looking to rent and less rental properties available to rent. This produces a perfect storm of high demand and low supply of rental properties, causing rents to rise strongly.

When the property prices start to go up again as demand increases, there is a shortfall of new properties being built (due to the developers not building during the downturn). At this time developers start to build again but there is a lag time before the new houses can be completed. This lack of supply puts more pressure on both house prices and rents to go up further.

Until equilibrium between supply and demand is realised or an oversupply of rental properties exists in the market, rents will continue to rise.

At 5%, this means you expect rents to double every 14 years. I bought a condo style apartment 28 years ago, (sold a while back, by the way) and recently saw the going rate for rents has moved up from $525 to $750, after all this time. The rent hasn't increased four fold.

If rents appear to be too low compared to the cost of buying the house, people tend to prefer to rent. On the flip side, if the rent can cover a mortgage and then some, there's strong motivation to buy, if not by the renters, then by investors who seek a high return from renting those houses, thereby pushing the price up.

The price to rent ratio isn't fixed, it depends in part on interest rates, consumer sentiment, and banks willingness to lend. Similar to stock's P/E, there can be quite a range, but too far in either direction is a sign a correction is due.

They are two different animals.

When you rent you are purchasing a service.

The landlord, as your service provider, has to make a profit, pay employees to do maintenance, and buy materials. The price of these things will increase with inflation, and that rolls into your rent price. Taxes also are passed to the tenant, and those tend to only go upward. Market forces of supply/demand will drive fluctuation of prices as well, as other posts have described.

When you buy, you are purchasing just the asset - the home. This price will also be driven by supply/demand in the market, but don't try to compare it to buying a service.