There's no question that the stock market achieved fantastic gains during President Trump's first year in office, with the S&P 500 index rising nearly 24%. Healthcare stocks performed even better. The Health Care Select Sector SPDR ETF (NYSEMKT:XLV), an exchange-traded fund (ETF) that attempts to track an index of top healthcare stocks in the S&P 500, racked up a gain of nearly 27% during President Trump's first year.

But why did healthcare stocks soar so much during the first year of the Trump administration? Some of the gains stemmed from the president's words and actions -- but there were also other major drivers. 

President Trump waving from Air Force One

Image source: WhiteHouse.gov.

Sum of the parts

Healthcare doesn't just include one type of business. When an industry makes up nearly one-fifth of the U.S. economy, it's too big to be that limited. The components of the Healthcare Select Sector SPDR ETF illustrate this point. Within the top 10 holdings of the ETF, you can find five distinct kinds of healthcare businesses.

UnitedHealth Group (NYSE:UNH) is the largest health insurer. Through its Optum business segment, UnitedHealth also runs one of the largest pharmacy benefits managers (PBMs) in the United States. If you're looking for a bellwether stock for healthcare payers, UnitedHealth Group is it.

Pfizer (NYSE:PFE) ranks as one of the biggest pharmaceutical companies in the world. The drugmaker's top prescription drugs include cancer drug Ibrance, anticoagulant Eliquis, and rheumatoid arthritis treatment Xeljanz. Pfizer also currently has a consumer healthcare business, which markets over-the-counter products including Advil, Preparation H, and Robitussin, but is considering selling or spinning off the business unit.    

Another top 10 holding of the Healthcare Select SPDR ETF is Medtronic (NYSE:MDT). The company develops and markets a broad range of medical devices, such as advanced surgical technology, insulin pumps, transcatheter aortic heart valves, and much more. Medtronic's current product lineup includes over 140 different types of medical devices and other medical technology.

The ETF's biggest stake, currently representing nearly 11% of the fund's investments, is Johnson & Johnson (NYSE:JNJ). J&J ranks as the single largest healthcare company in the world, with operations including pharmaceuticals, consumer healthcare, and medical devices.

It's important to understand this variety of healthcare businesses. Why? Different types of businesses benefited from or were negatively affected by different factors during President Trump's first year in office.

The Trump effect

There were three major ways that President Trump affected the performance of healthcare stocks during the first year of his term. One was a success for the president, another was a major failure, and the third was related more to what he didn't do.

The success was President Trump's signing into law the first major tax reform in the U.S. in decades. This tax reform included significant corporate tax cuts as well as allowing companies to bring cash parked overseas back to the U.S. at lower rates. 

Document with title "Trump's Tax Plan" next to book and glasses

Image source: Getty Images.

But did this tax reform really cause healthcare stocks to rise, since the law wasn't passed and signed until December? Actually, yes. I think that the mere anticipation of corporate tax reform served as an important catalyst for stocks in general throughout the year.

The major failure for President Trump, though, was not delivering on his promise to repeal and replace Obamacare. This lack of success helped insurers like UnitedHealth Group. Many insurers had already pulled out of state Obamacare exchanges before Trump took office. However, the Medicaid expansion part of Obamacare was a moneymaker for the health insurance industry. Keeping more people on the Medicaid rolls as the result of the failure to replace Obamacare was good news for health insurers.

Then there's what President Trump didn't do. Before taking office, he stated that pharmaceutical companies were "getting away with murder" and committed to shake things up. In particular, then President-elect Trump promised to "create new bidding procedures for the drug industry." Those comments caused drugmaker stocks to fall. But the President's words didn't turn into action. As a result, biotech and pharma stocks enjoyed big gains overall during the first year of the Trump administration. 

Smaller -- yet bigger -- stories

Of course, the reality is that the U.S. economy isn't driven entirely by what the president or the government in general does. Most healthcare stocks moved up or down as a result of how their businesses performed and what their future prospects are. Some of that is driven by laws and regulations, but certainly not all of it. 

UnitedHealth Group, for example, saw its stock soar more than 50% during President Trump's first year in office. Tax reform helped, but strong demand for insurance and Optum products was also important to the company's success.

A major catalyst for Johnson & Johnson was its acquisition of Swiss drugmaker Actelion. The pulmonary hypertension drugs gained with the buyout helped boost J&J's revenues considerably. In addition, the company did a good job protecting its top-selling drug, Remicade, from biosimilar competition while also enjoying strong sales growth for products like Darzalex and Stelara.

Some healthcare stocks lagged behind. Pfizer underperformed peers, primarily because of headwinds for its essential health segment. Medtronic stock didn't generate gains as impressive as many others did, with the company facing some negative impact after Hurricane Maria affected its manufacturing operations in Puerto Rico. 

When combined, these individual stories for companies had a greater impact than the "big" stories in Washington. President Trump rightfully deserves some credit for the tremendous performance by healthcare stocks, but definitely not all of it. That's likely to be the case in the remaining years of his presidency as well.

Keith Speights owns shares of Health Care SPDR and Pfizer. The Motley Fool owns shares of and recommends Johnson & Johnson. The Motley Fool owns shares of Medtronic. The Motley Fool recommends UnitedHealth Group. The Motley Fool has a disclosure policy.