That's one half of their job, the other half is to secure government infrastructure from exactly the type of attacks they use on other countries.
The problem there is that it sets up an incredible tension since how do you get the message out about a 0-day in windows to protect your 'own' side without your opponents getting the same message.
I've thought for years that the NSA doing both jobs is silly since one side will inevitably win that argument (as seems to be the case).
It needs to be a separate agency concerned purely with securing government and infrastructure from external threats with a decent firewall between the two sides (and possibly an oversight clearing committee to keep an eye on what both sides are up to).
Over here in the UK we have largely the same problem with GCHQ having a dual mandate.