The comparison most calculators get wrong is the deposit. Money used for a down payment would have been invested if you rented, and over a decade that opportunity cost is often larger than the mortgage interest. This models both paths to a net worth figure and shows the year, if any, at which buying pulls ahead.
A deposit is not spent, it is tied up. Rent instead and that money stays invested, along with every franc by which owning costs more than renting each month. At a 6% return, a 100,000 deposit becomes about 180,000 over ten years. That opportunity cost is frequently larger than the mortgage interest, and it is the term that decides most honest comparisons.
Buying costs roughly 2% in fees and taxes; selling costs 5 to 6% in agent commission and transfer duties. That is around 8% of the value gone before any comparison starts, which is why a home typically has to be held five to ten years before ownership pulls ahead. Buying for a two-year posting almost never works out.
The single answer at the end of your chosen horizon is less useful than the year the lines cross. If break-even lands at year eight and you are confident of staying fifteen, buying is comfortable. If it lands at year twelve and you might move in five, the calculation has told you something regardless of which side is ahead at year ten.
Tax treatment, which varies enormously by country and is often the largest single factor - mortgage interest deduction, imputed rental value, capital gains exemptions. Nor the things that are not financial: security of tenure against flexibility, and the freedom to change your mind.
Because the deposit, the purchase costs and every franc of ownership premium would otherwise be invested. At a 6% return a 100,000 deposit becomes about 180,000 over ten years. Add transaction costs of roughly 2% to buy and 6% to sell, and ownership needs meaningful appreciation before it catches up.
The first year in which the owner's net worth passes the renter's and stays ahead. Below it, renting left you better off. It is typically five to ten years, which is why buying for a short stay rarely works out.
Two, and they pull against each other: the rate the home appreciates and the return the renter earns on invested money. Small changes in either move the break-even year by years. Try the extremes rather than trusting one central estimate.
Steuervergleich Kanton Zürich — Gemeindesteuern vergleichen (Deutsch)