If you expect the price of your house to rise quickly, then it can be a good thing to invest in a home and re-sell it after only 3 or 4 years.
During the time you own the home, you will be able to deduct the real estate taxes you pay and the interest on any loans you use to buy the home. If, for example, your monthly payment is $1,200 including taxes and insurance, then probably about $1,000 of that can be deductible for most people. That helps with your overall cost of investing. Just so you get this point, if you rent for $1,200 you can't deduct anything. If you buy for $1,200 a month, after deductions your payment is really only about $920. True, you don't get the $280 back until you file, but it will come (unless Congress changes the law).
The downside is that buying and selling have transaction costs.
For a buyer you can expect to drop about 5% of the selling price in expenses related to closing, as a rule of thumb, but it could be less or more.
For a seller you can expect to drop about 8% of the selling price in expenses related to closing, as a rule of thumb, but it could be less or more.
So, 5% on the front end, mostly tax-deductible payments, followed by 8% on the back end. The price would have to rise by the 13% over the 3-4 year period for the investment to make sense. Of course, living in the house is a total bonus - it's mostly deductible, and you're living there: cool. But will the market rise by 10-15%? That no one can guarantee. It seems likely that inflation is coming. No one knows, though.