Add the lackluster performance of defense stocks to the long list of puzzling inequities in the pandemic stock market.

A custom basket of top U.S. defense contractors within the S&P 500 Index is down about 20% for the year, even as the broader benchmark pushed into the green briefly last week. That's significantly worse than the performance for S&P 500 railroads, restaurants, footwear makers and soft-drink companies.

Lockheed Martin, which reported second-quarter earnings on Tuesday, displayed the sector's resilience amid the pandemic upheaval. Earnings, sales and cash flow were all higher than the year-earlier period. At a time when most companies are hesitant to make any concrete predictions about the immediate future, Lockheed touted a record $150.3 billion backlog and actually raised its guidance on all fronts. And yet even after a respectable 2.6% gain on Tuesday's earnings report, Lockheed still trades at roughly 14 times its estimated earnings in 2021. The valuation discount to the broader S&P 500 is just shy of the widest spread in at least five years.

Fellow defense contractors Raytheon Technologies Corp., General Dynamics Corp. and Northrop Grumman Corp. are scheduled to report results this week, as is Boeing.

The reason for the defense sector's underperformance appears multifold. For one, defense contractors don't really fit with the technology-focused bent of the recent upswing in stocks. Second, as Congress debates injecting at least $1 trillion more in stimulus funds into the pandemic-stricken economy, the deficit is set to explode and the government will likely have to make up some of that spending elsewhere. The worry is that the U.S.'s gargantuan defense budget will be a prime target.

Any hit to military spending isn't likely to be as bad as what's suggested by current valuations, though. While the deficit may put a cap on military spending growth, the volatile geopolitical situation likely creates a floor. Historically, there's a weak correlation between deficit-related economic variables and military spending, Melius Research analyst Carter Copeland noted this month.

At the end of the day, "sentiment is fickle, while fundamentals are facts," Vertical Research Partners analyst Rob Stallard wrote in a report last month. "While we think defense companies can't do much about the slowing Department of Defense budget outlook, they are still growing and have good visibility, good cash flow and good valuations." What more do you want?