You don't get too greedy. Usually there's a reason why bubbles form (e.g. a housing shortage in SF and London, gentrification of a certain area in a certain city etc) and often there are secondary factors as well.
Having both a clear exit price and timeframe in mind when buying is probably a good way to do it. Even if a property bubble starts to collapse, there is usually still sufficient time to get out.
Property is one of those things where people are irrational about purchasing, which is good if you want to make money. Some people don't even care about the price -- they want to buy in 201X, and buy a property they shall.
If you believe property to be (significantly) overvalued, then you should rent instead of buy. If you're at the end of a "boom", then it's not unreasonable to wait it out and see how prices progress. Low interest rates also tend to push residential prices higher, because people can pay off more principal monthly vs less if rates are higher. When buying property it's almost always better to buy when rates are high and refinance later than to buy when rates are low.
Buying high and selling low is also definitely a thing. That doesn't necessarily mean you can't find a good deal somewhere (you can), but it'll be much harder.
Tldr: Unlike what most people believe, property is not a "sure thing" investment.
1. Pick a hot up and coming city.
2. Buy 5 properties at $1m each.
3. Sell in 2-4 years for double the value, preferably paying no tax on the capital gain at all if you (somehow) can.
Rinse and repeat. It's what happened in London in 2008-2014, etc.
You just, as an investor, need to be aware it's a bubble.