If a buyback happens, the market capitalisation drops by the amount of the buyback, and the number of shares drops by the same ratio, keeping the share price initially constant. The money goes to the investors who sell.
Buybacks are nevertheless good for investors who hold. They now have shares in a company whose market cap is 100% growing enterprise, instead of 90% enterprise and 10% bag of money. That means that if the company keeps doing well, the share price will increase faster than it would have done otherwise (it will also drop faster - it's no longer anchored to an inert pile of cash).