Soaring nearly 20% since this time last year, the S&P 500 has powered higher and higher, providing an even better return than the Dow Jones Industrial Average, which has climbed about 7%.

But not every stock has enjoyed such an impressive run this past year. In fact, two quality stocks, Cognex (CGNX -2.44%) and Brookfield Renewable (BEPC -0.70%) have headed in the other direction, falling 21% and 34% over the last year, respectively. Let's see why two Motley Fool contributors think the stocks are buys despite their recent declines.

Cognex's best days lie ahead

Lee Samaha (Cognex): Cognex stock is down 4% this year and 18.6% over the last 12 months. It's not hard to see why. The machine vision technology company's three primary end markets have all struggled recently. Its logistics end market (e-commerce warehousing) slowed last year as companies like Amazon slowed investment after a few years of heavy investment driven by the pandemic.

In addition, its consumer electronics end market (Apple is a Cognex customer) also slowed as smartphone and other electronics sales slowed, partly due to a correction from strong spending on consumer products during the pandemic and rising interest rates pressuring consumer spending. It's a similar story with the automotive industry, whereby rising rates slow automotive sales and production.

It's a story of near-term weakness, and it wouldn't be surprising if there were more near-term pressure coming when the company reports its first-quarter earnings in early May.

That said, this is a temporary weakness in a long-term growth story. Consumer electronics companies, including Apple, can only stay relevant by investing in new product development. That means more investment in production lines and machine vision technology that helps monitor and guide processes like aligning mobile phone screens.

Similarly, automotive companies must invest in electric vehicles to stay ahead of the competition. E-commerce growth isn't going away anytime soon, even if the growth rate was tempered out of the pandemic. As such, spending on e-commerce warehousing will grow again over time.

Cognex will see better days. The company has always had a bumpy growth trajectory, and its history suggests its growth recovery could be violent when it occurs. Its solutions add value to manufacturing and logistics activity and are part of the movement toward automated production. All told, it usually makes sense to be greedy about buying a growth stock when the market is fearful and fretting about near-term weakness.

Brookfield Renewable will make your passive income stream pop

Scott Levine (Brookfield Renewable): Unlike the situation with Cognex, the catalyst behind Brookfield Renewable's tumbling stock is not so clear. While the company itself has performed well, shares of Brookfield Renewable have plunged 34% since this time last year and 22% since the start of 2024. Despite the market souring on the stock, the investing thesis remains strong, and it remains a particularly appealing option for those looking to fortify their passive income with its ultra-high forward-yielding 6.4% stock.

Characterizing 2023 as a "record year for our business on almost all metrics," Connor Teskey, Brookfield Renewable's CEO, lauded the company's performance in its fourth quarter 2023 earnings report. The clean energy powerhouse, for example, set a high-water mark for funds from operations (FFO), reporting $1.1 billion -- a 9% year-over-yer increase. And it's not only the company's recent performance that is encouraging. Brookfield Renewable seems poised for continued growth, ending 2023 with projects totaling almost 24 gigawatts (GW) in the advanced stage of development.

The company's strong FFO growth contributes to the argument that Brookfield Renewable's dividend isn't at risk of being cut. Skeptics often balk at high-yield dividend stocks, fretting that the high payouts might not be sustainable, but the company's strong cash-flow generation suggests otherwise. In 2023 and 2022, Brookfield Renewable had FFO payout ratios of 80% and 84%, respectively. Pair this with the company's investment-grade balance sheet, and it seems that skeptics can rest assured that the dividend isn't likely to be slashed anytime soon.

Even more reassurance that Brookfield Renewable is a solid passive income play comes from the company's outlook. Targeting consistent 5% to 9% annual distribution increases, management projects 10% growth in FFO per unit from 2023 to 2028. Of course, there's no guarantee that the company will succeed in achieving these targets, but the company's track record of increasing its distribution at a 6% compound annual growth rate (CAGR) over the past 20 years and increasing its FFO at a 12% CAGR from 2016 through 2023 are encouraging signs.

Is now the time for you to click the buy button on these two beaten-down stocks?

Smart investors know that just because the market has punished a stock, it doesn't mean that the punishment has been warranted. Both Cognex and Brookfield Renewable have seen their stocks tumble recently, but the declines don't suggest that investors should keep their distance. For growth investors looking to grab a great growth stock, Cognex is certainly worthy of consideration, while income investors will want to dig deeper into powering their portfolios with Brookfield Renewable.