Also, the nonprofit is not under evolutionary pressure to actually solve the problem. They are just under pressure to make people believe they are doing a good thing.
Corporations dont tend to rationally shut down when their market goes away either, there are inefficiencies in the corporate model. Charities do change as demand changes though.
Eventually the corporation will be bankrupt, though. Still, I don't claim that corporations are without fail.
It is still necessary to think about "morals" (I don't like morals, because I think they are only necessary if you don't understand what is really going on). Otherwise, why not join the Mafia and make millions selling drugs?
It's a similar failing: there's a gap between the ultimate good provided by a non-profit and its metric for funding (which is why grant-writing is a much more sought-after skill than most programmatic work).
For corporations, there's often a gap between financial performance (particularly short-term) and real shareholder/owner value.
It's ethically important to see not just private gain (compensation) but also try to honestly assess one's positive impact on the world (though this does not discount, for example, donations to charitable causes, or the contribution to public goods through taxation).