The S&P 500 confirmed its presence in bull territory earlier this year by reaching a record high -- and just recently, it's shown its strength by roaring to yet another high. This momentum isn't over if history is a guide. That's because bull markets of the past have lasted considerably longer than bear markets -- nearly nine years versus 1.4, according to First Trust data.

So how can you benefit the most from these times of market growth and optimism? By investing in solid growth stocks that have what it takes to perform both now and over the long haul.

One of my favorites is a company most of us know pretty well. This company may deliver groceries and other merchandise to your door and entertainment to your TV or e-reader.

I'm talking about Amazon (AMZN 2.19%), a stock that's climbed 17% so far this year, buoying the S&P 500, and this company's gains may be far from over. Let's check out three reasons to buy Amazon like there's no tomorrow.

Two adults and a child smile while looking at something on a laptop.

Image source: Getty Images.

1. Leadership in two high-growth markets

Amazon is a leader in both e-commerce and cloud computing, markets Grand View Research forecasts will expand at compound annual growth rates of more than 18% and 21%, respectively, to 2030. This market position, and the fact that Amazon continues to improve its offerings, mean that as these industries grow, Amazon should greatly benefit.

In e-commerce, Amazon has put the focus on offering customers the lowest prices possible and achieving record delivery speeds. The company, through recent cost structure moves that I'll discuss, has decreased its cost to serve -- allowing it to cut prices on certain items and still maintain profitability. And in recent times, it's delivered orders at its fastest speeds ever. These two points are important to customers, so they should keep them coming back.

As for cloud computing, Amazon Web Services (AWS) dominates the global market and continues to expand, with a focus on the hot area of artificial intelligence (AI). It offers products and services across price ranges, so it may appeal to a broad variety of customers. In the most recent quarter, AWS, which generally drives Amazon's overall profit, reported double-digit growth in net sales and operating income -- so it's on track to continue powering the company's earnings.

2. On track to monetize artificial intelligence

Speaking of AI, Amazon could be among the first to monetize it. In the recent quarter, AWS reported an annualized revenue run rate of $100 billion, thanks to Amazon's investment in this potentially game-changing technology.

How is AWS generating revenue from its investment so quickly? Amazon is tackling AI from every angle, making it possible for the company to play a role in just about any AI project.

AWS sells the nuts and bolts to launch an AI program such as chips to train AI models -- and it offers everything from premium chips by leaders like Nvidia to lower-priced options Amazon has developed in house. For those who don't want to start an AI program from scratch, AWS also offers a fully managed service that gives customers access to top large language models that they can customize. Finally, Amazon also has developed a variety of apps, such as Amazon Q, a generative AI-powered assistant for software development.

The AI market is forecast to reach more than $1 trillion by the end of the decade, and Amazon's focus on this technology could make it one of the big winners.

3. A new cost structure that could boost earnings

Amazon has a solid track record of earnings growth -- but it has hit bumpy patches along the way. In fact, rising interest rates and the difficult economic environment weighed on the company back in 2022 -- so much that Amazon reported its first annual loss in nearly a decade.

The good news is the tough economic times prompted Amazon to revamp its cost structure, making moves that not only helped it recover in the short term but also set it up for long-term growth. Amazon took steps like cutting jobs and improving efficiency, and it also made a huge change in its fulfillment process that's lowered its cost to serve.

Amazon switched its U.S. fulfillment model to a regional one from a national one, bringing inventory closer to the customer. This is saving Amazon money, as mentioned, and it's also speeding up deliveries. So it's great for the customer and for Amazon -- a win-win situation.

These and other cost efforts put Amazon in great shape to succeed right now in the bull market and over time throughout market cycles. So right now is a fantastic time to buy Amazon shares hand over fist and hold on for the long term.