They are still able to actually make a profit (and quite often will, because careful balancing of perfect profit and loss is almost impossible and loss is bad), and I thought those profits were still taxed because otherwise that's too obvious as a tax dodge, it's just that profit isn't their main goal?
In the case of many/most (honest) non-profits, the operating costs are paid out of a combination of the dividends of an invested principal (endowment, having been previously donated by donors) and grants/current donations. Any operating profit could then be returned to the endowment, allowing the organization to maintain higher operating costs indefinitely, thus giving the organization more capacity to further their mission.