Okay, so yes, you are mechanically correct in that if you sold 10% of your shares for $1m, you would get the cash not the company.
However, the way funding events work in real life is that new shares are created by the company and then sold to the investors.
As a very math-simple example, I have 1m shares in my company, and I own 100% of them. Some VCs want to take a ~33% share of the company for $5m. My "board" (me) creates 500k new shares, and sells/gives them to the investors for $5m. Now there are a total of 1.5m shares, of which I own 1m, and the VCs own 500k.
EDIT: sometimes, though, a founder will sell part of their shares to the VCs during a funding event. That's usually to help give the founder a little liquidity and cash.