Indeed this can (and does happen) but the non-profit can loose its status if it starts doing stuff that does not further its purpose as stated by the bylaws. And the tax authorities can decide that your stated purpose would not be tax exempt (for example a union would not be tax exempt and neither would a collector society [think for example a numismatic society])