I used to volunteer for a local non-profit a few years ago.
From time to time, I would reflect on the fact that Microsoft and other commercial suppliers were getting paid for providing services to us, but I was expected to work for free.
For the same logic they are tax-exempt. There is a general consensus that their goal is the greater good (like developing sudo and such) and not the usual capitalistic good of generating more money.
Then again, you usual Friday outing of FANG engineers may have more money than some nonprofits too.
Greenpeace is a (non-profit) corporation. Unions are corporations. Municipalities. Colleges and universities.
* https://en.wikipedia.org/wiki/Legal_person
Should they have to pay?