First of all NASA job is not to make money. It’s a government agency, the government gives them a fixed budget to invest in the respective year
And NASA is funded by the taxpayer.
Although they earn a good amount of money by selling services to the aviation companies and sells payload space to commercial vendors launching satellites.
And $1 spend on NASA add $10 to their Economy.
And all the money goes to government treasure, as all the money the government gets is tax and the money should not be wasted.