The corporation selling shares is just primarily owned by the non profit
The corporation selling shares is subject to normal corporate tax regime
The real answer to your question is that non profits can own shares, and there is no legal difference between passive investment of other publicly traded companies and highly consolidated shares of a private company. In the US it is seen as merely happenstance that we have such a liquid market where the shares themselves can rapidly change in value and create profits, but there is nothing controversial about that.