The term non-profit organization is often misunderstood. This term does not refer to an organization that is prohibited by law from earning a profit (that is, an excess of gross earnings over expenses); non-profit does not mean ‘no-profit.’ It is quite common for charitable organizations to generate profits. The definition of a non-profit organization primarily relates to requirements about the distribution of the profits earned or otherwise received. This fundamental element of the law is found in the ‘doctrine of private inurement.’
The word non-profit, by the way, should not be confused with the term not-for-profit (although it often is). (For inexplicable reasons, the accounting profession prefers the phrase not-for-profit.) The former describes a type of organization; the latter represents a type of activity.
To reiterate: Both non-profit and for-profit organizations are legally able to generate a profit.