That's incorrect. A company's market cap includes any cash the company has. Buying stock means spending that cash but increasing the value of the stock by an equal amount.
Stock buybacks don't affect market cap.
Stock buybacks don't affect market cap.
Where why_only_15 is incorrect is in saying that buybacks don't affect share price. The whole point of a buyback is to increase the share price.
Consider a company with 1T shares that's valued at $1T with $100B of cash. Presumably, $100B of that valuation is for the cash, because investors know they could give that money back through dividends or the like. Let's say the company buys back 100B shares for its $100B. Because the company no longer has the cash, the overall value decreases (to $900B) to the same degree that there are less shares on the market (100B less).