You truly can not determine if you can afford to buy a place until you take a multitude of factors into account, and they vary for each person and each property.
Not to mention, housing has high fixed costs and just isn't available for a lot of people. You need a down payment, various closing costs, proof of decent credit (not just that you haven't defaulted on a loan, but that you've been actively building credit), and ofttimes proof of some moderately high amount of income or sustained bank balance. Even with enough income to make the monthly payments you could still have to save and plan for years to get over the hump of actually buying a home.
Once you've actually bought the house, your actual expenses are burstier than when renting. You might get lucky, but if the furnace or something dies in the first couple of years you won't be able to weather that loss if you were just on the cusp of affording home ownership (whereas a renter would be just fine because it's their landlord's problem). Since certain major components of the house are effectively self insured, that raises the bar for initial savings you need to purchase a house with the same financial safety as renting.
There's an additional assumption you're glossing over -- that for every apartment there exists an equivalent or worse house. At times when I needed really cheap rent I could grab a 200sq ft studio apartment, but that option isn't readily available for most home buyers.
Even assuming buying were feasible for everyone it still wouldn't be close to optimal. The extra fixed costs associated with a home purchase or sale make it much more difficult to move for family issues, school, job opportunities, .... If you're in a situation where you plan to move every couple years then renting is likely cheaper (certainly easier) than purchasing a home, even in places where the rent is higher than an equivalent mortgage.
And on and on and on. If you're going to stay somewhere a few years and have a bit of a financial buffer then I totally agree that home ownership is often a good idea. It's not that clear cut for huge swathes of people though.