One additional thing to keep in mind when using these rent vs. buy calculators is the input price for what you forecast the future sales price is one of the primary drivers of whether it makes sense or not to rent vs. buy. With interest rates as low as they are they really have nowhere to go but up over the next 5-10 years, you have to consider this impact on the sales price of the home. Even if buying is cheaper than renting, unless you plan on renting out the home when you move, you seriously need to consider what the resale market will look like. If you take a $500,000 home at 4% interest with 20% down, you will be looking at monthly payments of about $1,910 a month. If interest rates go up to 7% over the next few years, which is very feasible and closer to the historical average, that same house would have to sell for $358,000 to still be affordable at the $1,910 a month. That same house would cost $2,660 a month at $500,000 with 7% interest rates. Obviously, there are other factors at work such as inflation, and economic development of a region that will also influence prices, however this very reasonable expectation of longer-term trend in interest rates can create almost a 30% headwind against housing prices. Therefore, if you are relying on a 5-7 year time horizon of housing prices increasing with inflation, you may want to stress test this to see if it still makes sense under slightly more adverse conditions.
That being said, it can still make sense to buy if you know that you are going to be in place for a very long time, or if you can capture enough rent on the property to offset all associated costs, including vacancy if you were to move early and hold onto the property.