You have to factor in everything. It's not just rent payment vs. mortgage payment, it's everything you spend on housing (taxes, repairs, etc.) in two scenarios.
In any situation where the rental scenario results in extra cash flow that you then invest, you can end up ahead in total, sometimes significantly so. It's all complicated by the fact that you are rarely comparing rent vs. buy on the actual same property.
Remember also in the "buy" scenario you have to include closing costs etc. which can affect your timeline. Your 1yr is unrealistic, you'll eat 5-10% of sale price on just that, typically, which may be way more than rent.
In any situation where the rental scenario results in extra cash flow that you then invest, you can end up ahead in total, sometimes significantly so. It's all complicated by the fact that you are rarely comparing rent vs. buy on the actual same property.
Remember also in the "buy" scenario you have to include closing costs etc. which can affect your timeline. Your 1yr is unrealistic, you'll eat 5-10% of sale price on just that, typically, which may be way more than rent.