Investors on the market purchase these shares with the expectation to be profitable through: increase in share price (capital gain) or distribution of dividends.
When a company buys back shares, they are basically just purchasing shares from whoever had previously owned the shares.
The market (shareholders), which includes individuals, banks, insurance companies, pension plans, mutual funds, other companies, municipalities, foreign holders, etc... etc... etc....
Shareholders (in the market)