It isn't easy for corporations to perform well while the rest of the market tanks. Companies that managed to pull that off over the past year deserve some praise. But that alone isn't a good enough reason to buy their shares. Among those stocks that crushed the market, some will go on to provide market-beating returns over the long run, while others have less certain prospects.

Let's look at one company in each category: AstraZeneca (AZN 5.38%) and Biogen (BIIB 0.23%). Here is why the former is a solid buy, and why investors should hold off on the latter for now. 

The stock to buy: AstraZeneca

AstraZeneca is a U.K.-based pharmaceutical company with a long list of products, many of which are hugely successful and generate well over $1 billion in annual sales. The company's oncology lineup is particularly impressive, with products such as Tagrisso, Imfinzi, Lynparza, and Calquence, all of which are blockbusters.

AstraZeneca's oncology drugs made up about 35% of the company's revenue in the third quarter. This unit's sales grew by 15% year over year to $3.8 billion. AstraZeneca's second-largest segment is its cardiovascular, renal, and metabolism unit; it accounted for 21% of the company's total revenue in Q3 and grew its sales by 11% year over year to $2.3 billion.

Other key segments for AstraZeneca include its rare diseases operations, which it inherited through its 2021 acquisition of Alexion Pharmaceuticals. In the third quarter, rare disease sales came in at $1.7 billion for the company, 4% higher than the year-ago period and totaling 16% of the drugmaker's revenue. Overall, AstraZeneca's top line increased by a strong 11% year over year to about $11 billion.

In addition to a solid lineup, AstraZeneca can rely on its strong pipeline to accelerate growth over time. The company earned an impressive 19 approvals in the third quarter alone. Investors can expect plenty of pipeline progress this year, including new clinical trials and key data readouts. Approvals of brand-new drugs and label expansions for existing ones should also keep rolling in. 

AstraZeneca boasts 179 pipeline programs, including 13 new molecular compounds in late-stage studies. The pharma giant's lineup should only get stronger, leading to consistent revenue and earnings growth. AstraZeneca has been able to outperform the market over the past year for that reason, and it will likely deliver strong returns from here on out.

The stock to avoid: Biogen

Biogen is a major biotechnology company. It was not performing that well for most of 2022 until it announced positive interim results from an ongoing clinical trial for lecanemab, a potential therapy for Alzheimer's disease (AD). Biogen is partnered up with Japan-based Esai on this project. According to the data so far, lecanemab seems successful at slowing cognitive decline in early AD patients.

Biogen's shares soared on the news. And that's understandable. Plenty of companies have tried -- and largely failed -- to develop effective therapies for AD. Biogen and Esai seem to be getting closer to doing so. But there are some reasons to worry about Biogen's prospects. First, note that Biogen's current lineup is not performing well. Many of its products are facing competition (generic or otherwise) that is stifling sales growth.

Biogen's revenue has been declining over the past couple of years. 

BIIB Revenue (Quarterly) Chart

BIIB Revenue (Quarterly) data by YCharts

Furthermore, investors have put a lot of hope in Biogen's potential AD treatment. The company does have other pipeline programs and will likely earn other approvals. But unless it can impress the market with lecanemab, its shares will drop regardless of almost any other positive development. Is there any reason to be worried about lecanemab's future? Here's one. 

On its website, the peer-reviewed journal Science reported that there have now been two deaths that are potentially linked to lecanemab in its ongoing clinical trial. That raises concerns about the medicine's safety although it isn't anywhere close to a fatal blow to its prospects. Still, this highlights the point that something could go wrong for Biogen in this program, and if it does, its shares would likely plunge.

In my view, investors should wait before pulling the trigger on this biotech stock. If lecanemab does not encounter any headwinds moving forward, the company should be worth serious consideration. But until this story unfolds, Biogen looks like a volatile and risky prospect.