If the mortgage is equal to the rent, then potential landlords are leaving money on the table. That rarely happens for long. Typically most landlords in competitive markets will leverage and take up interest-only mortgages to the extent were rent only barely covers interest and maintenance, and make most of their money on capital gains.
For most people a repayment mortgage and maintenance and appropriate insurance should end up more expensive than renting for that reason.
It is possible to come out financially on top by owning, not least if you're willing to do maintenance yourself etc., but it's not nearly as clear-cut.
I've done very well buying, basically out of luck because I happened to buy on a tracker mortgage briefly before the interest rates crashed after the financial crisis, but if I'd foreseen that change I'd have been filthy rich instead of just a bit better off on my mortgage. But a tracker mortgage adds risk, and it could just as well have gone the other way. I took that risk because I could afford it.
For me, the main economic benefit is that it is a hedge against unforeseen rapid changes in housing costs. If the area I live in suddenly gets drastically more popular than nearby areas, then I can still afford to live here. The cost is that I take a risk with respect to making it harder to move, but with a son in school locally that is not something I'd consider lightly anyway, and that if interest rates swings the wrong way I may still end up paying more overall.