The real cost of each option
Renting costs the rent, and nothing else. Buying costs the mortgage interest, property taxes, insurance, maintenance and transaction fees, and returns to you the equity you build plus any appreciation. The comparison is between total rent paid and net cost of ownership after equity.
The mortgage principal portion is not a cost at all: it moves money from your bank account into your equity. Only the interest is genuinely spent, which is why the early years of a mortgage are much more expensive than the payment suggests.
Why the time horizon decides it
Buying carries large one-off costs at both ends: transfer taxes, legal fees and agent commissions commonly total 5 to 10% of the property value across a purchase and eventual sale. Those must be amortised over your holding period.
Stay two years and those costs swamp any benefit, so renting almost always wins. Stay ten or more and they spread thin while equity and appreciation accumulate, so buying usually wins. The break-even for most markets falls somewhere between four and seven years, which is what makes this calculator's time input the most important field on the page.
What the numbers leave out
This comparison assumes you would not invest the difference. If buying requires a large down payment that would otherwise have been invested, the opportunity cost of that capital is real and favours renting more than the raw numbers show.
There are also non-financial factors no calculator can price: security of tenure, freedom to renovate, and against those, the flexibility to move for a job at short notice. Treat the output as one input to the decision, not the decision itself.