With the S&P 500 index down over 22% year to date, it's been tricky finding companies outside the energy space that have beaten the market in 2022. According to Fidelity, every sector (excluding energy) is down so far this year, with the communication services, consumer discretionary, real estate, and tech sectors all down more than the market.

Finding companies that are beating the benchmark might be challenging, but it's not impossible. Both Chipotle Mexican Grill (CMG 0.39%) and Waste Management (WM -0.32%) have outperformed the S&P 500 so far this year, providing safety during this time.

If you're looking for safe stocks to invest in that could build wealth over the long haul while mitigating losses during bad times, these two are solid choices. Here's why.

The case for Chipotle Mexican Grill

Chipotle provides the best of both worlds for investors. Not only is it outperforming the benchmark year to date, but it also has smashed the market with 381% share-price growth versus the S&P's return of 45% over the past five years.

How is it providing generous returns? Chipotle has built itself on a powerful brand name that has attracted loyal followers. And these customers have been willing to buy Chipotle's burritos no matter the environment. This consistent demand has continued even during a precarious economic time like today. Therefore, while other discretionary food chains have struggled, Chipotle saw stable year-over-year revenue growth of 17% in Q2.

That's not the only reason Chipotle put up tasty results this quarter. The other reason is its pricing power. Due to the company's loyal fans, Chipotle was able to hike prices to diminish the impact of higher operating costs, and demand barely slumped -- signaling that its brand name is so powerful, consumers are willing to pay these higher prices. 

As a result, Chipotle retained its impressive profitability. In Q2, the company's store-level operating margin increased 70 basis points year over year to 25.2%. This helped diluted earnings per share soar 40% to $9.25 over the same period.

Chipotle's valuation isn't cheap at 55 times earnings, which is far more expensive than other fast-food chains. However, it might be worth paying this premium price. Chipotle's brand loyalty has been a major driver of its success, which could continue for the long haul, provided that the company keeps customers happy by continuing to deliver fantastic product quality and customer service. 

Chipotle can invest in these things to retain customers with this high profitability, possibly resulting in outsized returns for shareholders while providing less volatility in the share price. That's why this safe investment is one to buy now and hold a long while.

The case for Waste Management

If one thing is inevitable, it's that people will continue to generate trash for a long time. Therefore, one of the safest investments imaginable is the leader in garbage collection, disposal, and recycling -- Waste Management. 

The company is the dominant force across all trash operations in North America, with over 15,500 collection routes, 260 active landfills, and 550 collection sites. Because of this immense scale, the company controlled roughly 29% of U.S. landfill volume in 2021.

It's likely that Waste Management will maintain its leadership for a few reasons. First, it can cost millions of dollars to build an empire like Waste Management. Second, few citizens want a landfill in their backyard, so there can only be so many landfills in the U.S. These two factors make Waste Management's scale both expensive and difficult to replicate.

Thanks to this unrivaled dominance and high barriers to entry, Waste Management is giving a lot back to shareholders. Since roughly 2014, it has cut its number of outstanding shares by nearly 12%, while paying out a steady dividend. The company is on its way to becoming a Dividend Aristocrat, which includes companies that have increased their dividends every year for 25 years. Waste Management is in year 19, so its current dividend of $2.60 could be much higher in the future.

Like Chipotle, Waste Management has beaten the market this year, as well as over the past five years. Therefore, it strikes the perfect balance of growth and safety. Considering the company's stable competitive advantages, high barriers to entry, and lucrative shareholder-friendly actions, it's a stock worth holding for the long haul.