As well as the S&P 500 did in July, rising by more than 9%, there were a few stocks that did far better. Shares of HCA Healthcare (HCA -1.63%)Etsy (ETSY 0.21%), and Tesla (TSLA 4.30%) jumped by more than 25%. They were among the top-performing stocks in the S&P last month.

Let's have a look at what drove those strong results and whether these stocks can build off their impressive gains.

1. HCA Healthcare

HCA Healthcare operates healthcare facilities across the U.S. and can be a great way to gain exposure to the industry. Last month, the company released strong second-quarter earnings numbers, which gave the stock a boost, sending it up 26%.

In Q2, the company's revenue was largely unchanged at $14.8 billion (versus $14.4 billion a year ago). And even though the net income of less than $1.4 billion was down 17% from the prior-year period, it was still a solid performance by the business that was better than what analysts were expecting. Its adjusted per-share profit of $4.21 was higher than Wall Street estimates of $3.70.

The company is optimistic that it can continue improving on profitability as management noted that contract labor was high in the first quarter as a result of COVID-19. Those costs came down in Q2, and it expects to see even less of a need for temporary labor (e.g., nurses) as the year progresses, so investors were likely bullish on the news.

Year to date, shares of HCA are still down 17%, which is worse than the S&P 500's decline of 13%. However, with a modest price-to-earnings multiple of 10, there's definitely potential for the stock to rise higher, especially as hospitals resume normal day-to-day operations and if COVID doesn't weigh them down. HCA could make for an underrated buy as the year progresses.

2. Etsy

E-commerce company Etsy has endured a challenging year in 2022 (its shares have fallen 50%) as investors have been anticipating less traffic on its platform, given a return to normal in the economy. Plus, Etsy isn't a cheap stock -- it trades at more than 45 times its future profits (by comparison, the S&P 500 averages a multiple of just 18).

But Etsy has proven to be resilient, reporting 11% revenue growth for the period ended June 30, with sales topping $585 million. Net income, unfortunately, fell by 26% to $73 million as the company's operating expenses grew at a faster rate than the top line.

It was a positive development nonetheless that helped lift the stock by more than 40% in July (tops on this list). It gives investors hope that Etsy may succeed even amid inflation and concerns of a recession. However, this is not a trend I would expect to last the whole year as Etsy is known for being a more expensive option for shoppers than eBay, and that could start to hurt its business.

It may be safer to keep this stock on a watchlist rather than buy it right now as Etsy is still a risky growth stock to own, given its high valuation and the volatility it has shown this year.

3. Tesla

Electric vehicle maker Tesla also had a strong month in July, rising by 32%. Tesla released its quarterly numbers last month, with adjusted earnings per share of $2.27 for the three-month period ended June 30, beating analyst expectations of $1.81. Revenue of $16.9 billion, however, fell slightly short of the $17.1 billion that Wall Street was estimating.

Overall, it was still positive news at a time when many growth stocks have been struggling and battling the effects of inflation. The company's gross margins did worsen, and profits were down from the previous period. But on a year-over-year basis, Tesla still netted a profit of around $2.3 billion -- roughly double what it earned a year ago.

Tesla also announced that on Aug. 25, it will split its shares on a three-for-one basis. Although that won't change an investor's overall position in the company, it could make the near-$900 stock more accessible to investors who can't buy fractional shares

Year to date, Tesla's stock is down 18% and still trades at close to 80 times its future earnings. Despite the strong month, this isn't a stock I'd be loading up on right now since its valuation could put it under pressure as the year goes on and as investors continue to flock to more value-oriented investments.