Walgreens Boots Alliance (WBA -1.26%) is in the midst of a turnaround strategy that includes launching hundreds of health clinics. In recent years, Walmart (WMT 0.15%) has also shown interest in healthcare, opening dozens of health centers nationwide within its stores. But last week, Walmart announced it's giving up on that strategy.

Walgreens investors may be breathing a sigh of relief, knowing that the company won't have to worry about Walmart as a competitor in this arena. However, the strategy change may not be good news for Walgreens.

Walmart's recent announcement should raise some red flags for investors.

Walmart is closing all of its health centers

Walmart management had touted healthcare as a promising growth opportunity for the big-box retailer. The retail giant offered low-priced health and dental services that would provide consumers with cost-effective options. It would also give them more of a reason to visit their local Walmart, to not only shop but to also stop in and get a checkup.

Up until recently, Walmart promoted optimistic plans for healthcare. A year ago, the plan was to double its footprint and have more than 75 health centers across the U.S. by the end of 2024. Those plans changed dramatically. Walmart said late last month that it would close its 51 health centers by the end of July. It will also shut down its virtual healthcare operations.

A company spokesperson explained, "Healthcare is expensive to run. We were finding that the increased labor and operating costs environment, like with reimbursement, both public and private, made it difficult."

This isn't good news for Walgreens

Walmart closing down its health centers may sound like a positive development for Walgreens. After all, no one wants Walmart as a competitor. But the bigger takeaway is that a business with vast, diverse, and complex operations such as Walmart can't find a way to make its healthcare business profitable -- at least, not at a level it's comfortable with. And it's not as if Walmart generates massive margins. While it has reported $15.5 billion in profit over the trailing 12 months, that was on revenue of $648.1 billion, which equates to a profit margin of just 2.4%.

Walmart likely wasn't going into this hoping it would be hugely profitable. By offering low-cost health and dental options, odds are it knew the margins would be slim. And yet the actual numbers came in worse than expected. Labor costs have been rising in recent years and inflation certainly hasn't helped, either. A lot has changed since 2019 when Walmart first announced its ambitions for health centers. But as recently as last year, it was still expecting to launch more health centers.

This doesn't bode well for Walgreens. The company has invested billions into primary care operator VillageMD in an effort to open health clinics at its stores. And its aims are far grander than Walmart's; in 2021, it set out a target for 1,000 health clinics by 2027. But that goal looks doubtful with the company recently announcing it will shut down 160 VillageMD locations as it tries to improve profitability. In three of the past four quarters, Walgreens has incurred a net loss.

Unlike Walmart, Walgreens hasn't pulled the plug on its healthcare operations. And odds are, it isn't going to. The company cut its dividend this year in an effort to free up resources and strengthen its balance sheet. Last year, it also brought on a new CEO, Tim Wentworth, who has a strong background in healthcare. It doesn't appear Walgreens is doing anything but going all-in on its healthcare venture.

But if Walmart can't make it work with its far greater resources to pull from, I'm not optimistic that the pharmacy retailer will fare any better.

Walgreens faces a lot of uncertainty ahead

Walgreens is trying to turn around its stock by strengthening its margins and winning back investors. But with Walmart abandoning its health plans due to a lack of profitability, I'm inclined to be less optimistic that Walgreens can succeed where Walmart can't. While Walgreens may not be as aggressive on price as Walmart, it's still going to be an uphill battle to grow its operations and get out of the red.

Expect things to get worse for Walgreens. If the business can't prove it's on the right track and heading toward profitability, then this already struggling stock (it's down 46% in the past 12 months) will go lower. The most prudent option for investors interested in the stork is to wait on the sidelines and see how it progresses. Walgreens isn't a safer investment based on this Walmart news.