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.
I don't think this is correct either. A company's cash, or other assets, are not included in its market cap. It's just share price times number of shares outstanding.
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).
You should think of a stock buyback as another way of paying a dividend without triggering a taxable event for stockholders. The value transitions into a greater price of the now-fewer-outstanding shares.
Now think about how that "market price" of a share is determined. Surely investors will be valuing a company with $100B in cash higher than a company with $0 in cash.
Stock buybacks don't affect market cap.