After a wild ride through August, Bed Bath & Beyond (BBBY) stock is flailing again.

Shares fell after the company's business update last Wednesday failed to excite its investor base, and the latest update shows that there's a laundry list of challenges facing the home-goods retailer.

Comparable sales fell 26% in the latest quarter, and the company reported a loss of $325 million in free cash flow, meaning cash burn reached nearly $1 billion in the first half of the year. Management also announced cost-cutting measures, and a new financing package worth more than $500 million. But it's going to be difficult to turn around the business, especially given the macroeconomic climate, with interest rates rising and fears of a recession swirling.

Additionally, Bed Bath & Beyond and its peers have overstocked inventory to avoid the supply chain issues of a year ago, which has led to aggressive markdowns in retail. And consumer spending is shifting away from categories like home goods after the boom during the pandemic.

Bed Bath & Beyond's challenges aren't anything new. In 2019, the company brought in its recently ousted CEO, Mark Tritton, from Target to turn around the business. The company sold off banners like Christmas Tree Shops and Cost Plus World Market in order to fund improvements in the core business, but those efforts haven't yielded lasting results. As a result, Tritton was shown the door after the company's first-quarter earnings report this year.

There's never a simple explanation for any company's failure. Investors and customers have long criticized Bed Bath & Beyond for its cluttered stores, and said it was late to evolve with e-commerce. But there's another reason that better explains why the company could go bankrupt. Competition from Wayfair (W 5.52%) and other online platforms seems to have shredded Bed Bath & Beyond's leadership position in home goods.

How Wayfair ate Bed Bath & Beyond's lunch

Wayfair has been around since 2002. Like Amazon, it's consistently delivered strong top-line growth, riding the tailwinds in e-commerce. It established itself as a leader in home-goods retail thanks to its low prices, wide selection, and good customer service -- many of the same reasons that Amazon has been so successful in retail.

Along the way, Wayfair has stolen significant market share from Bed Bath & Beyond. The chart below shows trailing-12-month revenue at each company over the last 10 years (or since 2014 for Wayfair):

W Revenue (TTM) Chart

W Revenue (TTM) data by YCharts.

As you can see, Wayfair passed Bed Bath & Beyond in revenue early in 2020 as the COVID-19 pandemic started, and though both companies have seen revenue slide recently, Wayfair has maintained its lead. What's also noteworthy is that Bed Bath & Beyond's revenue had been steady prior to 2019, but started to fall as Wayfair approached the same level of revenue, showing it was losing the battle for market share.

There's another set of metrics that also show why Bed Bath & Beyond has struggled to compete with Wayfair:

W Gross Profit Margin Chart

W Gross Profit Margin data by YCharts.

As you can see above, Wayfair's gross margin has historically trailed Bed Bath & Beyond's by a wide gap. Though that may be partly due to the different economics of the e-commerce model, it also shows that Wayfair's prices aren't high enough to turn a profit. You can see in the operating-margin chart that Wayfair has been unprofitable throughout its history, except for a brief window during the pandemic when sales unexpectedly surged. Wayfair's business model is built to drive top-line growth, and the company aims to be profitable once it gains enough scale.

Bed Bath & Beyond, on the other hand, had a healthy business a decade ago with 16% operating margins, though they've declined steadily since then. Back then, Wayfair was just a fraction of the size it is today.

Investors: Beware of competition

Bed Bath & Beyond built a strong business, but the company was vulnerable to lower-priced competitors, especially in the e-commerce era. And a competitor that's happy to operate at a loss is the worst kind of a competitor a company can have. Amazon has run a similar playbook to put a number of brick-and-mortar chains in the retail graveyard. Among the victims of Amazon and Wayfair is Pier 1, the home goods chain that closed all 540 of its stores in 2020.

A quicker pivot to e-commerce and more aggressive price competition could have helped Bed Bath & Beyond stave off the threat from Wayfair, but the business likely would have been wounded no matter what.

The lesson here is that investors need to pay attention to competition. If one of your stocks is facing a fast-growing, unprofitable disruptor like Wayfair, you need to be especially wary that it doesn't turn into the next Bed Bath & Beyond.