You can read their website and find out, they address some things you mentioned in the first few lines:
https://www.nsa.gov/Cybersecurity/Overview/
Whether or not that justifies mass surveillance is a different question. I don’t think so. The NSA is a really, really big place. You could work there for a lifetime and not engage in illegal surveillance. I think getting rid of the bad parts shouldn’t require us to get rid of the good as well.