Investors experienced a bear market this year, which marks the second time in the past couple of years that has happened. It's been a challenging time on Wall Street, but let's look on the bright side. Despite its horrible performance this year, the S&P 500 is still up by 64% since it bottomed out following the pandemic-induced market crash in 2020.

The message is clear: Investing in stocks during a bear market is an excellent idea for investors with a long-term mindset. On that note, let's look at two stocks that are solid buys right now: Veeva Systems (VEEV -1.66%) and Medtronic (MDT -0.69%)

VEEV Chart

VEEV data by YCharts

1. Veeva Systems

There are two key reasons why Veeva Systems is a solid buy-and-forget stock; it boasts a solid competitive advantage in an industry ripe for growth. Consider first the company's moat. Veeva offers cloud-based solutions to life sciences companies. Regulatory compliance is paramount in this industry, and Veeva's solutions help its clients stay on the good side of regulators while bringing their products to market faster and more efficiently. 

Second, for Veeva's customers, jumping ship is a bit of a risky proposition. It would involve transferring a wealth of data, potentially slowing down or disrupting operations, not to mention the time it would take to get acquainted with the new platform. In other words, Veeva Systems benefits from high switching costs. How much room does the company have to grow? Veeva estimates there is a total addressable market (TAM) of more than $13 billion.

Veeva Systems recorded just $2 billion in revenue over the trailing-12-month period, along with $393.7 million in net income. There is plenty of whitespace remaining for the company, even within its current TAM, but that doesn't tell the whole story. The life sciences industry is worth a massive $2.2 trillion and growing, providing plenty more opportunities to Veeva Systems over the long run.

It has also started to make strides in other highly regulated markets, including the chemicals industry. 

There is one caveat for investors to consider. Veeva Systems' shares look pricey, with a forward price-to-earnings (P/E) ratio of 37 -- which is more than double that of the S&P 500 at 17. Veeva Systems' valuation is one of the main reasons it has lagged the market lately, although its revenue growth has also slowed, too. 

VEEV Revenue (Quarterly YoY Growth) Chart

VEEV Revenue (Quarterly YoY Growth) data by YCharts

These headwinds might make Veeva Systems volatile in the short run, but the company's long-term prospects remain strong thanks to its leadership in a niche software-as-a-service market. A decade from now, Veeva's relatively high forward P/E will mean very little compared to the gains it can likely deliver over this period

2. Medtronic 

Medtronic is one of the largest medical device companies in the world, with a vast portfolio of products across several business units. The healthcare giant has had a tough time since the early days of the pandemic as the outbreak contributed to a drop in medical procedures, thereby impacting sales of some of its products.

Although the pandemic is receding, some procedures haven't fully recovered. Further, Medtronic is dealing with the effect of economic troubles such as inflation like everybody else. Short-term concerns aside, though, Medtronic is riding the wave of powerful, long-term tailwinds. Consider the world's aging population and the increased need for medical technology to care for the elderly.

Medtronic has a solid track record as it has produced innovative products constantly over the past few decades. The company earned more than 200 approvals over the past 12 months. Medtronic plans to spend $2.7 billion on research and development efforts during its fiscal 2022, and it is running more than 230 clinical trials. So it seems likely that there are many more approvals on the way for the company. 

Reputation is important, especially in the medical field. Earlier this year, Medtronic was once again featured among Fortune magazine's most admired companies, ranking second among corporations within the medical products and equipment category. This ranking considers several factors, including innovation and the quality of a company's products and services. 

Medtronic, which is based in Ireland, has developed a solid reputation among medical experts, who look to the healthcare giant for products that can impact the lives of their patients. This matters for investors focused on the long game.

Here's one more reason to buy Medtronic's stock: It has raised its dividend for 45 consecutive years, making it a Dividend Aristocrat. The company's 3.25% dividend yield is well above the S&P 500's 1.82%. In today's challenging environment, a blue chip company that generates consistent profits, offers growing dividends, and has plenty of room to grow is exactly what the doctor ordered.