Finding stocks that have long-lasting megatrends working in their favor can be an excellent way to generate new investment ideas. This notion is especially true when the businesses are market share leaders in their niche.

Two companies that meet these requirements are American Tower (AMT -0.27%) and Public Storage (PSA -1.07%). If people are using data or need room to store things, these two stocks will likely benefit. With total returns of 760% and 3,590% since 2000 compared to the S&P 500's mark of 540%, these stocks have a history of beating the market.

Here's why I believe the future looks just as promising, making these stocks magnificent dividend stocks for investors looking for a lifetime of passive income.

1. American Tower

American Tower is the leader in communications real estate, with over 148,000 towers, 1,600 distributed antenna systems, and 28 data centers across 24 countries. This massive presence makes the real estate investment trust (REIT) the largest operator in the United States and the third-largest tower company globally.

The REIT leases space on its network of towers to telecommunications companies like Verizon Communications, AT&T, and T-Mobile in the U.S. and is a critical ally to those companies as they build out their 5G ambitions (and beyond). Through each new iteration of mobile network deployments, from 2G, to 3G, to 4G, and now 5G, American Tower has only grown in importance, which helps to explain its market-beating past.

However, what's more important for investors is that this outperformance looks like it should have every opportunity to continue. A recent Ericcson Mobility Report estimates that U.S. mobile data traffic will grow by 22% annually through 2029. This growth rate shows no signs of slowing as data-dense applications like video and music streaming show nearly limitless demand.

In addition to this unwavering mobile data traffic growth, Altman Solon Research and Analysis projects that data consumption from the Internet of Things will grow by 39% through 2028. These bleeding-edge technologies often rely upon American Tower's infrastructure and provide yet another tailwind for the company.

Despite these megatrends supporting its future growth trajectory, American Tower trades at 19 times cash from operations (CFO) -- well below its 10-year average.

AMT Price to CFO Per Share (TTM) Chart

AMT Price to CFO Per Share (TTM) data by YCharts.

I like to use CFO in American Tower's case because it shows the cash the company brings in before accounting for what it spends on capital expenditures (CapEx) on adding new towers and maintaining existing ones. However, what makes the company a powerful investment opportunity is that the vast majority of its CapEx spending is revenue-generating (new towers), rather than revenue-maintaining (tower upkeep).

This allocation of CapEx means that American Tower could produce robust free cash flow with minimal upkeep, making its steadily growing dividend very safe.

AMT Cash from Operations (TTM) Chart

AMT Cash from Operations (TTM) data by YCharts.

The company has grown its dividend -- which currently yields 3.2% -- by 17% annually over the last five years, thanks to this robust cash generation. Even with this steady dividend growth, American Tower's revenue has also grown by 9% each year.

I see this balanced combination continuing far into the future, especially as the company distances itself from the effects of selling its India-based towers to Brookfield Infrastructure.

2. Public Storage

Real estate investment trust (REIT) Public Storage accounts for roughly 9% of total storage space square footage in the U.S. and is the market share leader in this niche. In addition to this immense physical scale, Public Storage also leads in terms of mind share among the public, with its orange logo the most recognizable brand in the space.

The company's top-dog attributes don't stop there. Public Storage's cash-generating prowess is easily best-in-class compared to its four largest publicly traded peers.

PSA Owners' Cash Profits Margin (TTM) Chart

PSA Owners' Cash Profits Margin and Cash ROIC (TTM) data by YCharts.

Partially thanks to this robust cash generation, Public Storage is the only U.S. REIT with A2 and A credit ratings from Moody's and S&P Global. This pristine balance sheet, the company's top-tier FCF margin, and high cash return on invested capital (ROIC) combine to make Public Storage a desirable investment proposition, considering that the self-storage industry is highly fragmented. 

Combined, the four peers in the chart above only amount to roughly 20% of the total self-storage square footage in the U.S. The remaining 80% are local and regional operators that can't match Public Storage's scale, making them potential acquisition targets.

With its robust cash ROIC of 14%, Public Storage has a long history of successfully growing through mergers and acquisitions, leaving the company well-positioned to continue dominating its niche.

The cherry on top for investors? Public Storage currently pays a 3.4% dividend that has grown by 17% annually over the last decade. While the company doesn't necessarily raise its payments every year, it has delivered strong growth when viewed over a longer time horizon.

With 75% of its customers signing up to rent digitally -- compared to its REIT peers' average of 30% -- Public Storage should thrive as tech-savvy Gen Z users opt into the company's digitally native platform and drive the next wave of its growth.