Just when you think the bull market is here to stay, POW! Stocks get shellacked. The S&P 500's recent tumble reminds investors they can never completely let their guard down. Stocks may slip back into a bear market just yet.

If that's what's in the cards, it wouldn't be wrong to start thinking about repositioning your portfolio to a more defensive posture.

To this end, here's a closer look at three of the top stocks to buy during a bear market. They've each got defensive businesses that not only hold up in tough times but can even thrive in a weak economy.

1. Hormel Foods

It's easy to assume one food company's stock is just as good as another. After all, it's just food.

In reality, however, the packaged and prepared food business can be approached in a myriad of ways.

Take Hormel Foods (HRL 0.29%) for instance. It doesn't sell raw beef or chicken like Tyson Foods, nor does it sell canned fruits and vegetables like Del Monte. Rather, Hormel is the name behind several complete heat-and-eat meal options like Dinty Moore beef stew, Hormel chili, Spam, and Lloyd's barbecue, just to name a few.

What does it matter? The competitive difference is the cost structure of producing fully prepared foods and the pricing power of these same products.

As for pricing power, although it's cheaper to fully prepare a meal from raw ingredients at home, it's also more time-consuming than opening a can or a tub of ready-to-heat foods. Consumers will pay a premium for convenience -- even when they're looking to save money by cutting back on trips to restaurants.

On the cost front, prepared-food packagers must pay for all the same ingredients you do to make a complete meal. Because they're buying in bulk, however, they can do so more cost-effectively than consumers can.

Connect the dots; the more like a finished meal a food product is, the more marketable it is to consumers and the more ways a company has to keep its input costs contained. These are savings and pricing power that other food companies like Tyson and even Del Monte just don't have a chance to capitalize on for themselves.

Hormel's executive vice president of retail operations, Deanna Brady, explains this balanced competitive edge best with a comment she made during the company's second-quarter earnings call:

We're seeing consumers be extremely intentional about their spending, not only where they're shopping, how they're shopping, and then what types of items they're buying. As a result, we continue to see consumers gravitate toward, surprisingly, our premium offerings... think about a party tray or Columbus charcuterie board, those are items that are bringing value to their lives.

In other words, Hormel is able to offer value at a somewhat premium price even when consumers are feeling fiscal stress (which bear markets can certainly help spur).

2. Walmart

It's the same idea -- just a different tack. Discount retailer Walmart (WMT 0.62%) offers consumers plenty of bang for their buck when money is tight, when prices are high, and when incomes aren't entirely secure.

Granted, this has always been the case. The ability to offer this value has proven game-changing, however, while the economy, as well as the stock market, have been wobbly in recent months.

To fully appreciate this competitive advantage, one only has to compare last quarter's results from other retailers to Walmart's. Take higher-end department store chains Nordstrom and Macy's, for example. Although Nordstrom topped revenue estimates for the three-month stretch in question, its top line still tumbled 8.3% year over year. Macy's revenue suffered a similar dive. Both companies also voiced concerns about weakening consumerism.

Walmart's close competitor, Target, isn't firing on all cylinders either, despite being able to offer more affordable discretionary splurges. Its top line fell 4.9% year over year during the second quarter, while same-store sales slumped 5.4%.

These numbers suggest consumers are tightening their purse strings in a big way. That's not quite the case, though. As Hormel's Brady explained, consumers are just rethinking how and where they spend their hard-earned money. And as a result, they are increasingly shopping at Walmart. Its second-quarter sales defied the broad trend by growing 5.7% year over year, and same-store sales in the United States jumped 6.4%.

And yes, it seems Walmart is poaching at least some of Nordstrom's and Macy's higher-income shoppers. Echoing comments made for several consecutive quarters now, CFO John Rainey noted during the retailer's Q2 earnings call:

With respect to high-income consumers, we continue to see share gains across all income demographics. I think encouragingly for us in the quarter, the number of categories that we saw share gain in actually expanded. But this has been pretty consistent for five or six quarters now and it really points to the fact that our value proposition is resonating with customers.

Look for more of the same in the event of a prolonged marketwide weakness.

3. McDonald's

Last but not least, add fast-food chain McDonald's (MCD 0.33%) to your list of top stocks to buy during and because of a bear market.

The same premise that applies to Hormel Foods and Walmart applies to McDonald's, too. That is, the restaurant chain provides measurable value when higher-end eating options are decreasingly affordable.

It's already happening, in fact, thanks to rampant inflation and despite the lack of extreme market bearishness. As CFO Ian Borden commented during the company's second-quarter conference call, "We are seeing some consumers that are kind of trading down from those more premium or higher-priced items in the menu to more core and value." Borden goes on to say this shift "speaks to our leading value for money and affordable positioning in the U.S. business."

CEO Christopher Kempczinski added some interesting color to Borden's comment, pointing out, "If you look at [households with] incomes under $100,000, we're actually doing quite well there, which suggests that we're getting some benefit from trade down, from things like full-service dining, casual dine, et cetera."

To put the subjective observations into a more numerical context, McDonald's worldwide same-store sales were up 11.7% year over year for the three-month span.

There's no reason to think the fast-food chain won't continue serving consumers who've been priced out of more expensive restaurant options either. Broad bearishness should have a similar effect by making consumers feel like their overall net wealth is at risk of shrinking.