Or even if you plan on living in it, if you want to make money when it comes time to sell, and not just break even, after accounting for total cost of ownership.
Most people who think they sell their house for a modest profit are wrong.
This is generally true regardless of the location, with the caveat that hot markets are more likely to have more professionals participating that know how to include those costs.
Often people see those higher prices as greedy profit (or as artificially high in order to gentrify, etc.), and developers do need to make a profit, but often times a large part of the elevated price is just including hidden costs that homeowners don't account for.
But looking at it from the other side, developers/investors are only going to enter markets where they believe there's a margin for profit. Which generally means those neighborhoods are a bit underpriced to begin with.
And speculation and investing are the same thing, except the former is often used in a pejorative way.