WASHINGTON — American lawmakers have for years been assailing companies for dodging taxes with overseas maneuvers. But now that the European Union has done something about it by trying to wrest billions of dollars from Apple, those officials have offered a response viewed by many as rife with hypocrisy: collective outrage.

Tax avoidance has become a lightning rod as the presidential campaign has taken on a strong populist cast, and leading Republicans and Democrats in Congress have demanded that companies be forced to pay their fair share. Both Hillary Clinton and Donald J. Trump have vowed to crack down on deals that allow companies to relocate their headquarters overseas to lower their tax bills, and the Treasury Department has made limiting international loopholes a priority.

Despite all that, Apple — a company long accused of being overly creative at avoiding taxes — now has the federal government standing up for it after the European Union’s executive commission ordered Ireland on Tuesday to collect $14.5 billion in taxes from the company.

And for at least some American politicians, the anger stems from a simple calculation: The tax money that the European Union extracts from Apple should be going to the United States Treasury, not that they have figured out how to make that happen.