Nonprofits categorically are not tax exempt, tax exempt nonprofits are.
And the reasons that (as well as the actual terms, conditions, benefits, and restrictions under which) exemption to is offered to them varies for different subtypes of nonprofits eligible for taxation. But he main overarching basis is that business taxation is a tax on profits of entities which can be redistributed to do group of owners/members/shareholders/etc., and serves to discourage using the business as a vehicle by those people for tax avoidance, whereas tax exempt nonprofits generally do not have such claims against their assets.
For charities (to which donations are also tax deductible beyond the org beyond exempt), there is additionally the idea that they are serving a public function (which, yes, makes the designation of churches as tax exempt charities problematic, and arguably contrary to the spirit, if not the case law, of the First Amendment.)