The comparison is usually set up wrong
Rent is compared with the mortgage payment, and ownership wins whenever the payment is lower. That is the wrong comparison twice over. Part of a mortgage payment is repayment of principal, which is not an expense at all; it is saving. And ownership carries costs that never appear in the payment: maintenance, insurance, taxes, and the very large one-off cost of buying and later selling.
The comparison that means something is between rent and the true cost of ownership: interest, maintenance, insurance, taxes, and the transaction costs spread over the years you expect to stay.
Transaction costs and the break-even horizon
Buying and selling a house is expensive in fees, taxes, searches and moving, and all of it is paid at the two ends. Spread over twenty years those costs are small annually; spread over two years they are enormous. This is why the honest answer to 'should I buy?' begins with 'how long do you expect to stay?' Below some horizon, buying is arithmetically worse almost regardless of what prices do, because the costs of the transaction have not had time to amortize.
Maintenance is an owner's hidden rent
A house consumes itself slowly. Roofs, heating systems, windows, drainage, decoration and appliances all have finite lives, and the fact that they fail irregularly does not make them irregular costs — it makes them costs that arrive without warning. A renter pays for this too, inside the rent; the difference is that the owner pays it in lumps, at times not of their choosing, and is responsible for arranging the work.
What renting actually buys
- The ability to move at short notice, which is worth real money in an uncertain job.
- A known monthly cost with no exposure to a boiler, a roof or a rate change.
- No exposure to a fall in prices, and none to a rise either.
- Freedom from the time cost of arranging repairs, which is not nothing.
What owning actually buys
- Control: what the place looks like, and whether you have to leave.
- A fixed housing cost in nominal terms if the rate is fixed, while rents follow the market.
- Forced saving, since part of every payment reduces a debt.
- Exposure to the housing market, which is a benefit or a cost depending on which way it goes.
Why there is no general answer
The two sides trade different things, and the exchange rate depends on facts that are personal: how stable your work is, how likely you are to move, how much disruption a large unexpected bill would cause, whether you want to alter where you live, and how much you value not having to ask permission. Local conditions matter as well — the ratio of rents to prices varies enormously between places and moves over time.
Treat published rent-or-buy calculations as a way of seeing which assumptions the answer is sensitive to. Usually it is sensitive to two: how long you stay, and what maintenance really costs. Both are things you know more about than any calculator does.