Sometimes, being nice isn’t being helpful.

Wall Street has been awfully nice to Amazon even as the e-commerce giant faces its greatest business challenges in years. Those challenges—most notably an overbuild of its fulfillment network just as pandemic-boosted demand started slipping—have resulted in Amazon losing 40% of its market value over the last 12 months. That is by far the worst performance among trillion-dollar market cap tech peers Apple, Microsoft and Google-parent Alphabet, the three of which have averaged a loss of about 6% in that time.

But 92% of analysts still rate Amazon as a buy—compared with 74% that do so for Apple, according to FactSet. What is more, many are expecting the company’s current slump to be quite short-lived. Current estimates have Amazon’s retail-related segments, which encompass its own online stores, third-party sales and physical stores, rebounding to double-digit growth in the third quarter and staying there through the end of the year. Amazon’s closely watched operating margins are also expected to recover to the 4%-5% range the company enjoyed before its recent slip in that same time.

That seems optimistic considering the work the company still has ahead. The Wall Street Journal reported last month that Amazon is working to sublease at least 10 million square feet of excess warehouse space. The company is also deferring construction of new facilities on land it has already bought, and renegotiating existing leases with outside warehouse owners. The Journal also reported Thursday that 23-year Amazon vet Dave Clark, who ran the company’s retail and logistics operations, presented a three-year turnaround plan for those divisions to Amazon’s board on May 25—just days before he resigned from the company.

Even positive analysts are a bit worried. Mark Mahaney of Evercore ISI wrote earlier this month that Wall Street’s outlook for Amazon’s operating income this year is too high given the company’s continuing effort to address excess capacity; Mr. Mahaney’s target is about 26% below the current consensus.

And this week, Brent Thill of Jefferies wrote that traffic to Amazon’s home page remains “sluggish,” and cited his interview with a logistics expert who predicted the company won’t reach “equilibrium on head count and capacity” until the first quarter of next year. And a fresh concern was raised Tuesday by Brian Nowak of Morgan Stanley, who noted that layoffs at many privately held tech startups could end up hurting Amazon’s AWS cloud business, which has long been a popular enabler of young tech companies looking to get off the ground fast. All three of these analysts have buy ratings on Amazon’s stock.

Amazon also announced Thursday that its Prime Day sales event will start July 12. That could end up skewing comparisons even more, as last year’s event took place near the end of the second quarter rather than the typical slot near the beginning of the third. It will also be Amazon’s first Prime Day under new chief executive Andy Jassy, whose first year in charge has been plagued by addressing the overshoot on capacity expansions the company put into place before his promotion. High targets from Wall Street don’t make things any easier.

Write to Dan Gallagher at dan.gallagher@wsj.com