Why does Gödel's Second Incompleteness Theorem undermine Hilbert's program?

First, as others have pointed out, your characterization of GIT1 is not right. What it actually roughly says is that any complete and consistent theory stronger than PA cannot be generated by a decidable set of axioms. This does kill the prospects of a single formal system that decides “all of mathematics” which was one of Hilbert’s loftier goals.$^*$

But another big aspect was to have a finitary proof on the consistency of such a system that underlies mathematics, which still makes sense as a goal even if that system is necessarily incomplete. For example. we could say the system is ZFC, which we know allows us to formalize most of known mathematics, even if we also know there are statements it can’t decide (provided it is consistent).

I have a few qualms with the argument that a proof of Con(S) in S would not tell us much, but for the most part I agree, so I’ll grant it for the purposes of this answer. However, the goal is much more ambitious than this: we want to prove the consistency of our system of mathematics (say ZFC) in a very weak finitary theory of arithmetic (say PRA), not merely in ZFC. Surely it would be desirable and meaningful if that could be carried out. However, if GIT2 tells us ZFC can’t prove it, then certainly a weaker theory like PRA can’t either. So GIT2 is indeed bad news for this aspect of the program.

$^*$ I’m a lousy mathematician but an even worse historian. What I say is based on my understanding from the folklore of what Hilbert’s Program was and may or may not correlate with anything Hilbert actually said or believed.