market cap = book value + discounted future cash flows = share price * number of outstanding shares
When you do a buyback, the book value drops (company loses cash), but the discounted future cash flows remains unchanged. The number of outstanding shares also drops.
The net result is the stock price increases as a company accumulates cash and uses it for buybacks because the number of outstanding shares drops.
Another way of thinking about it is that it's the same as dividends, but the dividend only goes to the sellers of the stock during a buyback.