When you invest in a company, it should be because you believe in its long-term potential. Part of this belief is understanding that volatility is inevitable, and there will undoubtedly be some tough weeks, months, and even years along the way.

Regardless of how this past year has gone, Apple (AAPL 1.27%) and Walmart (WMT 1.32%) are two stocks I believe you should buy and hold until you retire.

1. Apple

With a market cap of over $2 trillion, Apple is the most valuable public company in the world. For perspective, its market cap is more than five times Walmart's. With its world-class product and services ecosystem, Apple has cultivated a level of brand loyalty that's second to none (I assert, as I type this on my MacBook, while wearing an Apple Watch, with an iPhone beside me and AppleTV playing in the background).

AAPL Market Cap Chart

Data by YCharts.

Apple's bread-and-butter product is undoubtedly the iPhone, which accounts for 47% of its sales, but its continued top-line growth will be powered significantly by its entrance into the financial services space. It first teased those plans in 2014 when it launched Apple Pay, but that was more about convenience than anything.

The debut of Apple Card was a signal the company was getting more serious, but it still relied on a middleman, Goldman Sachs, to handle the underwriting and financial portion. Apple Pay Later -- the company's "buy now, pay later" service -- was the final "if you haven't been paying attention, maybe you should now" move from Apple. And not because of the service itself, but because it's the first time Apple is underwriting and funding loans itself.

The global financial technology market was just over $115 billion in 2021 and is expected to grow to more than $936 billion by 2030. As Apple begins playing in the fintech field, it has an edge that no other fintech can match: its smartphones and devices are in the hands of billions of people worldwide.

People gravitate toward convenience, and what better company to make a traditionally inconvenient system like the financial system simpler than the $2 trillion company that built its empire on doing just that?

2. Walmart

After a share price decline of more than 7% in the past month, Walmart finished 2022 down roughly 2%. There's no cash cow quite like Walmart, as it earns more revenue than any other company in the world. In the third quarter of its fiscal year 2023 (FY23), it made over $152.8 billion in revenue, up 8.7% year over year. This growth likely won't slow down, either.

Amid tough economic conditions and with fears that a recession is looming, Walmart will surely lean on its value pricing to capitalize for the foreseeable future. And it's this value that separates Walmart from competitors like Target (NYSE: TGT). For example, when it comes to groceries, which account for more than half of Walmart's sales, Walmart generally provides lower prices across the board compared to Target.

Beyond the short-term economic conditions that should boost its top line, Walmart is well-positioned for the long term for two main reasons. First, its core business model is undeniable. Value will never go out of style, as people will always be looking to save money. And with Walmart's pricing power, few (if any) businesses can compete with it on the scale at which it operates.

The second reason you can count on Walmart as a long-term investment is its commitment to expanding its revenue streams. It still lags noticeably behind Amazon in e-commerce, but it's taking steps in the right direction. In Q3 FY23, Walmart's e-commerce sales grew 16% year over year, but more impressive was the 30% growth of its global ads business.

Regardless of its lucrative core business, investors should be encouraged by Walmart's growth in non-consumer shopping areas. Invest, and let it lead you into retirement.