It cannot be intelligence gathering because it’s ineffective, as seen by its never stopping any terror attacks. It cannot be spying on Americans, because its SOP of “gathering it all”, again renders it ineffective.
Here’s the answer in my opinion, from Paul Craig Roberts:
The main function of the National Security Administration is to collect the dirt on members of the house and senate, the staffs, principal contributors, and federal judges. The dirt is used to enforce silence about the crimes of the security agencies.
That goal is doable.