Stocks, you just sit and wait and hope. In Real Estate, you can improve the property to increase rents.
As with most things in life it's highly dependent on what you pay for the asset for a margin of safety. One can't control future property taxes, insurance costs, maintenance, mortgage rates which will affect buyer's capacity to borrow and can influence selling values, will the government continue to subsidize RE and mortgages, etc, nor can one prevent an area from going into short to long term decline. Contrary to what some working in RE want to believe, RE is a very illiquid asset, especially if one misjudged the purchase price and can't afford to take a loss. The current RE tax benefits can be good, but who knows what that will look like down the road, you have depreciation recapture when you sell, and the estimated holding period going into an investment may be affected by outliers beyond your control.
I know a couple that live a few miles from us that are Darden School grads and are quite bright, but they are ~ $180k down on what was a $425k house in a good subdivision. Anyone can make a mistake and when it is RE the exit alternatives aren't always easy.
I have done well with the commercial and residential RE investments we own as well as the stock market, neither are always easy to manage. Leverage is a dual edged sword, liquidity can be a great thing if one doesn't like a lot of added stress in one's life. It is a lot easier to manage gains and tax losses in a brokerage account for future income tax offsets vs paying a mortgage on property that may not appreciate.