The broad market surged during Donald Trump's first year in office, as the S&P 500 gained 24% in the year starting from the president's inauguration. A booming economy, and excitement about the tax bill that was finally signed into law in December, helped propel the market to a blowout performance in Trump's first year.

However, retail stocks widely lagged the broader market; the SPDR S&P 500 Retail ETF (NYSEMKT:XRT) gained just 11% during that time and was trading lower for most of the year. Through Nov. 9, the retail ETF (exchange-traded fund) was actually down 8.6%, but a strong round of third-quarter earnings reports helped retail stocks rebound, and that momentum continued through the passage of tax reform and a successful holiday season.

Still, retail stocks have clearly lagged the market, and some retailers have been downright crushed. Let's take a look at some of the forces that have pushed retail shares down over the last year.

A mannequin and a wall of shoes inside a store

Image source: Getty Images.

1. E-commerce is crushing brick-and-mortar

Retailers that lost the most during Trump's first year are the ones that are getting trampled by e-commerce competitors. Mall-based operators, in particular department-store chains, widely saw same-store sales fall last year due to declining mall traffic. Chain operators like Macy's (NYSE:M), J.C. Penney (NYSE:JCP), and Sears Holdings (NASDAQOTH:SHLDQ) closed dozens, if not hundreds, of stores each, and dozens of other chains announced mass store closings or even declared bankruptcy. In what's become known as the "retail apocalypse," 2017 saw a record number of store-closing announcements -- about 8,000.

Companies like Macy's and J.C. Penney are seeing growth in e-commerce, but it's not enough to counteract the losses in the brick-and-mortar channel, especially as Amazon (NASDAQ:AMZN) only takes more market share. Apparel retailers have also struggled as Amazon stepped up its focus on the sector; it is set to become the nation's largest apparel retailer. Fast-fashion competitors like H&M, Uniqlo (a subsidiary of Fast Retailing), and Zara (owned by Inditex) have also taken share from traditional American retailers like Gap Inc. (NYSE:GPS).

Notably, e-commerce retail stocks like Amazon, Etsy, Wayfair and others surged last year.

2. An overstored country

The rash of retail bankruptcies and store closings isn't only due to competition from e-commerce. The U.S. also has many more stores per capita than similar economies; its retail square footage per capita is more than six times that of Europe or Japan. Urban Outfitters (NASDAQ:URBN) CEO Richard Hayne last April predicted a reckoning in the industry similar to what happened in the housing sector, saying:

Our industry, not unlike the housing industry, saw too much square footage capacity added in the 1990s and early 2000s. Thousands of new doors opened and rents soared. This created a bubble, and like housing, that bubble has now burst.

Even as retailers are faring better than they were a year ago, an inevitable rightsizing of the retail space in the country seems likely, especially as e-commerce sales are growing by about 15%. As shopping online becomes more popular, landlords are increasingly turning to service businesses like gyms to drive traffic. Going to the mall to shop is becoming a thing of the past.

3. A surprising turnaround

Starting in November, retail stocks got a surprising boost on a number of better-than-expected earnings reports. The corporate tax cut passed in December also favors retailers above other industries, as the retail sector has traditionally paid higher effective tax rates; many other industries have more of their operations abroad, and get tax credits for things like manufacturing or research and development.

Strong holiday sales reports from department-store chains and other retailers have also propelled sector stocks upward recently. However, the challenges of e-commerce and an overstored environment aren't going away. Walmart shares dove recently after the company's earnings report, as strong sales growth did not increase earnings as much as investors expected. That pattern could be repeated by other retailers, as e-commerce sales generally have lower margins than in-store sales.

Stronger retailers like Walmart have been doing well. But weaker, mall-based retailers seem like they'll continue to struggle, even with the benefit from the tax cut, as the headwinds facing the sector may only become more intense.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool’s board of directors. Jeremy Bowman owns shares of J.C. Penney. The Motley Fool owns shares of and recommends Amazon and Wayfair. The Motley Fool recommends Etsy. The Motley Fool has a disclosure policy.