Let's say you purchase $3,000 of Vanguard S&P 500 (the minimum mutual fund purchase price, I believe). To oversimplify, Vanguard takes $3,000 and buys the biggest 500 companies in the stock market with that money. It expands it's S&P 500 fund when you buy shares, and it sells some when you sell some. The entire thing is a giant bag of shares from every company on Standard and Poors (S&P) list of 500 stocks.
But it's more complex in reality, without defying the general outline I mentioned above. Vanguard keeps a small percent of the fund in cash to deal with purchases and sales. It then uses derivatives to simulate that cash as being in the market. Also, it doesn't just hold 500 stocks, it holds about 509 stocks. That way when someone tries to guess what stock will be next added to S&P's list, Vanguard already owns it (when two companies in the S&P 500 have a merger, it leaves an open slot in the S&P 500).
The way ETFs work would probably just scare you more, so I typed that up then deleted it. :) But ETFs also react to demand by purchasing more shares of S&P 500 companies, it's just done by outside institutions reacting to market demand for ETF shares.