Buying stocks right now can seem like a bad idea given that the stock market isn't on firm footing, with the S&P 500 down 16% this year. But the volatility in 2022 can create some attractive buying opportunities for long-term investors.

A couple of attractive stocks to buy right now are Jazz Pharmaceuticals (JAZZ 0.28%) and Alibaba Group Holding (BABA 1.45%). These stocks don't trade at inflated earnings multiples, and they have some great growth potential in the years ahead.

1. Jazz Pharmaceuticals

Jazz Pharmaceuticals is a drugmaker that transformed its business last year with the $7.2 billion acquisition of GW Pharmaceuticals, the company behind the only cannabis-based drug on the market, Epidiolex, that has obtained approval from the Food and Drug Administration. That has helped diversify Jazz's portfolio, which also includes products that treat narcolepsy and cancer.

But the big opportunity is in growing Epidiolex, which treats seizures. Jazz is expanding the indications for its use and launching the drug in more countries. In the company's most recent quarter, for the period ending Sept. 30, sales of Epidiolex totaled $196.2 million and grew 22% year over year. The company's narcolepsy medications, Xywav and Xyrem, combined for $512 million in sales, up by 11%.

According to analysts from Grand View Research, the market for cannabis pharmaceuticals will grow at a compound annual rate of 104.2% until 2028, indicating a huge opportunity for cannabis-based drugs. Having Epidiolex in its portfolio allows Jazz to tap into that potential.

Across all of its products, Jazz anticipates that by 2025, its total annual revenue will top $5 billion. Last year, the company's sales came in at just under $3.1 billion.

Year to date, shares of Jazz are up 16%, but the stock is still a good buy, trading at a forward price-to-earnings (P/E) multiple of only 8, well below the S&P 500 average of 18. The healthcare stock could be a steal of a deal for long-term investors.

2. Alibaba Group Holding

Chinese tech giant and top e-commerce retailer Alibaba has struggled with growth lately, as the company's sales have been slowing amid COVID-19 lockdowns in the country. There wasn't much excitement about Singles Day recently, a key shopping day in China. Alibaba didn't boast about sales or even disclose how much revenue it generated, only to say it was in line with last year's performance.

Those aren't encouraging things to hear for a company that over the years has generated impressive revenue growth and has been a top Chinese stock to own. Earlier this year, Alibaba also posted its first decline in revenue since going public in 2014.

BABA Revenue (Annual) Chart

BABA revenue (annual); data by YCharts.

Alibaba's challenges aren't unlike those of many U.S.-based tech companies that are laying off workers because demand isn't strong. And in China's case, the situation is even worse with COVID lockdowns.

While Alibaba's stock is struggling right now, down 40% year to date, in the long run the business can -- and likely will -- recover from this slowdown. With its e-commerce, its cloud business, and digital and entertainment services, Alibaba offers a great way to invest in the Chinese economy. 

The stock trades at a forward P/E of only 9, which compensates for some of the risk and uncertainty ahead. This is a bit of a contrarian investment right now, but it's one that can pay off significantly if you're willing to buy and hold for years.