Miles,
To illustrate, consider a simple cap weighted index containing two nearly identical firms. Each initially has a market cap of $10 B, a share price of $100, with 100 M shares outstanding. A cap weighted fund is equally invested in the two.
Firm A pays a $2 dividend. When it goes ex-dividend, its share price falls to $98, it still has 100 M shares outstanding, and a market cap of $9.8 B.
Firm B instead spends the same $200 M on a buyback. If the stock was fairly priced in the first place, and can stretch the buyback over enough time that liquidity isn't an issue, the buyback does not impact the stock price. (Since you assume differently, we'll come back to that in a moment.) Firm B now has 98 M shares outstanding. Now in the beginning, the two firms were nearly identical, and both are now $200 M poorer in cash, so if $9.8 is a fair market cap valuation for firm A, it is also a fair valuation for firm B, implying that $100 remains a fair share price for firm B. So there was no reason for the buyback to have changed the share price in a reasonably efficient market.
So after the two firms have returned money to shareholders by different means, they both have a market cap of $9.8 B, and a cap weighted index would equally weight the two.
But the cap weighted fund is now 50% invested in A, 49% invested in B, and has 1% cash, and needs to buy B or sell A to return to the index's weight.
Insofar as its investors reinvest their distributions, the fund uses the dividend cash to purchase B to return to the index weighting.
But insofar as its investors take their distributions as cash, the 1% cash will be used to pay distributions, and the fund must instead sell A and use the proceeds to buy B to return to market weighting.
Short version: when some firms in a cap-weighted index pay dividends and other firms do buybacks, a fund tracking that index needs to sell shares in the buyback firms and buy shares in the dividend firms to remain on index.