While most of Wall Street focuses on the next few quarters, smart investors know that the best returns accrue over many years. It takes time for companies to build and capitalize on enduring competitive advantages, after all.

A longer time horizon is a valuable trait for an investor in any climate, but especially during periods of elevated pessimism. With that in mind, let's look at two growth stocks that were dragged down along with the wider market in 2022. Read on for some good reasons to buy Palo Alto Networks (PANW -2.82%) and Lululemon Athletica (LULU -0.17%).

1. Palo Alto Networks

Investors are avoiding tech stocks right now on fears of a global economic slowdown potentially striking in 2023. But that short-term worry shouldn't keep you away from this promising cybersecurity business.

Palo Alto Networks recently raised its growth outlook after sales increased 25% through late October. The software-as-a-service leader also notched another quarter of profitability, adding weight to management's claim that the business can deliver both sales growth and expanding profit margin. Palo Alto is on pace to generate ample free cash flow this year, too, giving it lots of resources it can direct toward extending its market share lead in 2023 and beyond.

Yes, tech budgets will shrink in a recession. Palo Alto Networks is already seeing signs of a slowdown in its deal negotiations. But cybersecurity is a priority for most enterprises, which implies some degree of recession resistance for market leaders. In any case, this growth stock has a good shot at expanding sales and profit margin over the long term, which should help deliver market-beating returns for its shareholders.

2. Lululemon Athletica

Lululemon has just about everything an investor could want in a growth stock. It has a strong brand in a huge global industry and the business routinely delivers market-leading sales and earnings metrics. Revenue jumped 29% in the most recent quarter, for example, as operating margin rose to a blazing 21.5% of sales through late July.

Many investors are worried that these figures will worsen when the company announces its fiscal Q3 results in early December. Consumers are pickier about their spending as high inflation persists. Rival Nike warned about a glut of inventory that's likely to pressure its profit margin at least into early next year.

Yet Lululemon outperformed its peers through the last several quarters, in part thanks to its popular lineup of athleisure apparel. More success along those lines should translate into solid returns for investors as the company extends its reach into new geographies, new demographics, and new product lines. It will take a few years for these gains to become obvious, but patient investors are being offered an attractive discount for that lack of clarity.

Thanks to general market pessimism you can buy Lululemon stock at below 7 times annual sales compared to a P/S ratio of nearly 9 at the start of 2022. Given its excellent long-term prospects, that valuation drop seems like a great reason to take another look at this investment. Looking back in five years, you'll likely be glad that you did.