Selling doesn't do an on-chain transaction though. It's only on-chain when you withdraw (or deposit).
Coinbase is an exchange, you're exchanging with other Coinbase users. Wallets only come into play if you're moving crypto in or out of Coinbase. That's a good thing, wallet transfers can be slow and would really make trading a pain.
Not if it's internal to coinbase -- can all be marked against an internal ledger, right?
Buying and selling does not access a backend wallet. Only when it is transferred outside of the exchange do you need to actually touch the blockchain.