For example, the NASA contract to Aerojet Rocketdyne to manufacture RS-25 engines is costing $146 million per engine. Each SLS launch will toss four of these engines in the ocean for a total cost $580 million. And that's just the engines of the core stage. For the cost of a single engine, they could have instead purchased an entire Falcon Heavy launch, which has two-thirds of the SLS lift capacity (and has to obey the same laws of physics as SLS).
SLS is the price NASA had to pay to get Congress off its back.
This isn't just a NASA thing, a NASA contract is probably pretty small compared to getting a new military base, or keeping one open that the military wants to close.
Having a well functioning space program? Doesn't benefit them much or at all.
Ultimately, it's because voters don't call them on their BS. If you've been a NASA fan, encouraging NASA funding regardless of what it's for, you're part of this problem.
Where do you suppose the need for so much energy comes from?