Nvidia (NASDAQ: NVDA) shares have soared 650% since January 2023. Consequently, its market capitalization has jumped from $360 billion to $2.7 trillion in less than two years. Demand for artificial intelligence (AI) systems was the driving force behind that price appreciation.

Amazon (AMZN 2.19%) and Alphabet (GOOGL 0.83%) (GOOG 0.80%) are currently worth $1.8 trillion and $2.2 trillion, respectively. However, both companies could eclipse Nvidia's current valuation within four years, meaning they could be worth at least $2.8 trillion by mid-2028.

Here are the important details.

1. Amazon

Amazon reported stellar financial results in the first quarter, beating expectations on the top and bottom lines. Revenue increased 13% to $143 billion as advertising and cloud computing sales accelerated. Meanwhile, generally accepted accounting principles (GAAP) net income tripled to reach $0.98 per diluted share. Investors have good reason to think that momentum will continue.

The investment thesis for Amazon centers on its strong presence in e-commerce, digital advertising, and cloud computing, markets projected to expand at annual rates of 11%, 15%, and 21%, respectively, through 2030. Amazon runs the most visited online marketplace in the world, and its clout in retail has evolved into a robust digital advertising business. Specifically, Amazon is the largest retail advertiser in the U.S. and the third largest adtech company worldwide.

Amazon is using artificial intelligence (AI) to increase revenue and boost efficiency across its e-commerce and advertising businesses. For instance, machine learning models optimize warehouse inventory and last-mile delivery routes, and a new generative AI tool helps brands create marketing content in a cost effective manner. Amazon has also shifted to multiple regional fulfillment networks (rather than one centralized network) and introduced ads on Prime Video. Those changes are not strictly related to AI, but they should boost profitability.

Meanwhile, Amazon Web Services (AWS) is the largest provider of cloud infrastructure and platform services. The company lost a percentage point of market share over the last year, but it remains well positioned to benefit from AI. Public clouds are the most cost-efficient way for businesses to get the computing power needed to build and run AI applications, so AWS has a significant advantage in its market leadership. However, the company has also expanded its portfolio with new products like Amazon Bedrock.

Going forward, Wall Street expects Amazon to grow sales at 10.9% annually over the next five years, a reasonable estimate given how quickly its major markets are projected to grow. Assuming Wall Street is correct, the stock could achieve a market capitalization of $2.8 trillion within four years if shares trade at 3.1 times sales in mid-2028. That seems reasonable, given that shares currently trade at 3.2 times sales.

What would that mean for investors? If Amazon is worth $2.8 trillion in mid-2028, shareholders will see annual returns of approximately 11.6% (from its current market capitalization of $1.8 trillion). Those gains would probably beat the S&P 500 (SNPINDEX: ^GSPC), given that the index has compounded at 10% annually (more or less) over long periods.

2. Alphabet

Alphabet looked strong in the first quarter. Revenue increased 15% to $80.5 billion due to especially strong sales growth in Google Cloud and modest sales growth in Google Advertising. Meanwhile, net income jumped 61% to $1.89 per diluted share as the company continued to focus on expense management.

The investment thesis for Alphabet centers on its strong presence in digital advertising and cloud computing, with markets forecast to grow at annual rates of 15% and 21%, respectively. Alphabet is the largest adtech company in the world, due in large part to its dominance in internet search. Alphabet is experimenting with generative AI to fortify that dominance. For instance, CEO Sundar Pichai says recently launched AI Overviews are boosting Google Search usage and user satisfaction.

Similarly, Google Cloud is the third-largest provider of cloud infrastructure and platform services, but the company gained a percentage point of market share over the past year and its recent launch of Gemini could sustain that momentum. Gemini is a multimodal AI model -- meaning it can be prompted with text, images, video, and other media -- that Google Cloud customers can use to build generative AI applications.

Going forward, Wall Street expects Alphabet to grow sales at 10.5% annually over the next five years, a reasonable estimate (perhaps a little low) given how quickly its major markets are projected to expand. Assuming Wall Street is correct, the company could achieve a $2.8 trillion market capitalization within four years if shares trade at 5.9 times sales in mid-2028. That seems easily done since shares currently trade at 7.1 times sales.

What would that mean for investors? If Alphabet is worth $2.8 trillion in mid-2028, shareholders will see annual returns just north of 6% (from its current market capitalization of $2.2 trillion). Those gains would probably underperform the S&P 500. That said, I believe Alphabet will be worth more than $2.8 trillion in four years, and I expect the stock to beat the market between now and then.