>A stock buyback is theoretically the same as a dividend
I don't think that is true at all.
A dividend is literally "We are paying out some amount of cash. If our stock price is $40 and we give $5 to each shareholder the shares should immediately go down to $35". Although since the stock price should be a NPV of the company's cash flow, they technically have even less working capital to create returns over the years, so I think the price should go down by even more than $5.. but that's a different discussion...
In a stock buyback.. let's say the price is $40 and they buy the equivalent of $5 back from the market. Well.. yes they gave away $5 but they also gained $5 of value because they are now holding the shares. It's a net zero transaction if their stock price doesn't change from it. Which.. it shouldn't unless you think it's a signal of something. Yes there's a bit more details, but value is not "given away" in the same sense.
In the dividend example, the company gave away money.
In a stock repurchase, they gave away money in return for shares of (almost) equal value.