The answers listed previously, are accurate with exchanges. Then you have coinbase.com which is not an exchange its more of a conversion mechanism. For BTC to Fiat and vice versa. I came to this stack based on a query as to how they replenish their supplies during rallies like the current ATH we are seeing now.
I think exchanges and sites like coinbase buy and sell from each other. They may do this via a large exchange like bitfinex or stamp, or even smaller exchanges. This is also most likely automated and built upon algorithms that watch for the most favorable exchanges and maximized profits. Large exchanges have lots of coins that can be bought and sold over and over again.