Basically - you're trying to avoid the scenario where you live in a place so short that the exchange cost you pay to flip it on the far side exceeds the amount of rent you'd pay to reside in it.
Determining the exchange cost isn't always straight forward - the 6% given above may or may not be realistic for you, there are some brokers that will take a 1% cut and those folks are more common in hot markets, and there may also be taxes you need to take into consideration.
Also, there is a risk of getting stuck with a lemon - if you purchase a house which seems fine but actually has extensive water damage and mold you could lose a portion of the value, this is a really significant consideration in quiet housing markets (like the midwest) and less important in areas like SF where most of the property's value is likely the land itself - in either case you're taking a big chunk of the value of the structure out of the equation when reselling the property but in the later case the value of the structure is rather minimal while in the former case the land is essentially free.
Basically you almost always want to buy if you are able to. The money you're spending on housing when you own a property is accruing as equity instead of being siphoned off by a landlord.