You could easily get a 38% return in the stock market if you used similar leverage, FYI.
Which no reasonably well-informed person would recommend, and certainly not to the degree that is commonly used to purchase a home.
In my view a family home is the primary investment many people will have. And it is an investment by the dictionary definition and I've always approached it that way. In our case we bought a triplex and have zero out of pocket costs after taxes. The rents from the other two units pay our mortgage and expenses. It has increased 35% since we purchased it in 2012 - about 70k a year. We live in a HCOL area.
Luck? Meh. Just part of the cycle. Our place we bought in 2009 did nothing for seven years - no appreciation - and then up 35%. The historical long-term average rate of appreciation in our city for the last 50 years has been 7%. Been up times, flat times and down times. I'm not sure, but this is likely similar to desirable areas of the US like Hawaii, San Francisco and LA. Our ROI far exceeds stock market returns.
Can leverage work against you? Yes, if you have to sell. Controlling that risk is really important. Buy and be prepared to hold - just like with stocks. Rental income helps mitigate this risk on a primary residence. In our case, we will sell one of our HCOL houses shortly to lock in gains. Being a landlord is not a lot of work, but other investments are truly passive and that is where we'll go next.
I would agree buying for cash flow without leverage is lower risk. These types of deals are usually not available in HCOL areas though - highly desirable areas tend to appreciate, but have terrible cash flow. That is why if you are living in one it might make sense for you to buy for a place to live plus rental income, but as a pure investment it would be too high of a risk for me given the recent appreciation and the fact that we are FI now and don't want to take these types of risks.