The stock market has given investors a difficult time in 2022, which is evident from the 10% decline in the S&P 500 so far. But this is also an opportunity for savvy investors to buy shares of some solid companies at attractive valuations.

Amazon (AMZN 1.60%) and Advanced Micro Devices (AMD -0.34%) are two such companies that have borne the brunt of the stock market sell-off. Amazon stock is down 14% so far in 2022, while shares of AMD are down 30%. However, the tech giants have been in rally mode since the beginning of July thanks to the broader stock market recovery.

Amazon stock has gained 31% since the beginning of last month, while AMD is up 37%. I think it's a good idea for investors to buy these hot growth stocks now, as they could head higher in 2022 and beyond. Let's look at the reasons why.

1. Amazon

Amazon is currently trading at three times sales, which is lower than its five-year average sales multiple of 3.87. Investors shouldn't miss this opportunity to buy Amazon stock at this relatively attractive valuation given the company's latest results, which point toward better times ahead.

Amazon released its second-quarter 2022 results on July 28. Its revenue increased 7% year-over-year to $121.2 billion, beating consensus estimates of $119 billion. The tech giant followed up its better-than-expected showing with a solid outlook, forecasting sales of $125 billion to $130 billion in the current quarter. That would translate into 13% to 17% year-over-year growth, suggesting that Amazon's growth is set to pick up.

The company's diversified business streams helped it overcome the softness in the e-commerce segment last quarter. While online sales were down 4% year-over-year to $50.8 billion, strong growth in advertising, cloud, physical store sales, and subscription services led the company to stronger-than-expected results.

Amazon Web Services (AWS) revenue, for instance, was up 33% year-over-year to $19.7 billion. The segment produced 16% of the company's top line. AWS' growth was driven by the addition of new products and services, which should help the company maintain its dominance in this market. More specifically, Amazon controlled 34% of the cloud infrastructure market in the second quarter.

Synergy Research Group estimates that the cloud infrastructure space has generated $203.5 billion in revenue in the trailing twelve months ending June 2022. With the cloud computing market expected to clock 17.4% annual growth through 2030, Amazon is in a solid position to record incremental revenue growth thanks to its impressive market share.

Meanwhile, the advertising business is turning out to be another key growth driver for the company. The segment generated $8.75 billion in revenue last quarter, an 18% increase over the prior year. Amazon has generated $16.6 billion from the advertising business so far this year, translating into an annual revenue run rate of over $33 billion.

There's a lot of room for growth in Amazon's advertising revenue in the long run. The company's access to the data of millions of customers and subscribers, and its massive reach across the globe, make it an ideal choice for digital advertisers. With the digital advertising market expected to clock 17% annual growth through 2027 and generate over $1 trillion in revenue, this segment could turn out to be another big money-maker for Amazon, and drive the company's long-term growth.

All these catalysts indicate why Amazon's earnings are expected to grow at an annual rate of 33% for the next five years, making it a solid growth stock to buy for the long haul.

2. Advanced Micro Devices

AMD proved why it is a top semiconductor stock to buy following its latest quarterly report. The company's chips are used in a variety of applications ranging from computers to gaming consoles to data centers to cars. This diversification helped it deliver a solid set of results at a time when other semiconductor companies are struggling.

AMD's second-quarter revenue shot up 70% over the prior-year period to $6.6 billion. Adjusted earnings were up 67% year-over-year to $1.05 per share. More importantly, the chipmaker reiterated its full-year guidance. AMD sees revenue growth of 60% in 2022 to $26.3 billion. Analysts expect the company's earnings to increase 57% in 2022 to $4.37 per share, but don't be surprised to see AMD deliver stronger growth, as its margin profile has improved following the acquisition of Xilinx.

So AMD looks set to sustain its hot rally in 2022. That's why investors should consider buying AMD stock without further delay, as it is trading at 42 times earnings, well below its five-year average earnings multiple of 102. A forward price-to-earnings ratio of 23 points toward healthy growth in AMD's earnings.

Even better, AMD has lucrative catalysts that should help it sustain its terrific growth in the long run. The data center market is one of them. AMD's data center revenue shot up 83% year-over-year in the second quarter to $1.5 billion as demand for its server processors remained robust. AMD's server processors are used by leading cloud service providers including Amazon, Microsoft, Baidu, Oracle, and Google.

The server processor market is expected to hit $52 billion in 2026. AMD has generated $2.78 billion in data center revenue in the first two quarters of 2022. The potential size of the end market suggests that there is a lot of room for AMD to grow its revenue. The good part is that AMD is consistently taking market share away from Intel in the server CPU space.

Mercury Research reports that AMD finished the second quarter with 13.9% of the server CPU market under its control, up from 9.5% in the year-ago period. The chipmaker looks well-placed to take more share away from Intel, as it is on track to launch new server processors this year that could reportedly perform better than the latter's offerings.

All this indicates that AMD remains a resilient semiconductor bet despite the negativity around companies from this sector, and investors are getting a good deal on the stock right now that they may not want to miss.