You tella car company that you're going to pay them a half million dollars for a special custom car. You sign the contract, which requires that you pay them $500000 and that they give you a car when it's completed. Halfway through the process you suddenly decide that you don't want the car after all.
Well, tough. You already signed the contract and they're already building the car. You have no choice but to pay for a car that you aren't going to use.
That's what goes on in vases like this. The government signed the contract saying that they'll pay. They can't renege on the deal just because they decided they didn't want what they were paying for any more, so instead they have to pay for it and let it gather dust once they have it. I can guarantee that if you or I signed a contract that said we'd pay for something we wouldn't be able to get out of it just because we no longer wanted what we were paying for.
This isn't so much about grandstanding politicians that want money for useless programs, but about grandstanding politicians who like to decide the government doesn't want something for which the contract has already been signed.