There are different types of stock indexes that deal with dividends differently. Index funds will also behave differently depending on which type of index they track, which is often indicated in the fund name by an abbreviation such as “TRN”.
The standard version of the S&P 500, e.g., is a price return (PR) index: It only takes into account the share prices, ignoring any dividends. That means that, typically, the index will fall slightly when one of its stocks pays a dividend. An index fund tracking the S&P 500 doesn’t need the dividends it receives in order to match the index, so it will forward them by paying a dividend itself. However, it is impractical for the fund to pay a dividend whenever one of the 500 stocks in the S&P 500 has done so; instead, it will keep the cash until some fixed day (e.g. each quarter) on which it distributes the money to the fund owners.
The other relevant type of index is the total return (TR) index. In it, any dividends are considered immediately reinvested. A fund tracking such a total return index will need to keep any dividends it has received or it will fall behind its index; therefore, it doesn’t pay dividends itself, and instead will use the cash to buy more stocks (according to the index weighting). From the point of view of the owner, the fund price will grow more rapidly than for an equivalent PR index fund.
Since funds typically won’t actually get the full dividend amount – a percentage is withheld as tax –, there is also the net total return (TRN) index, a variant of the TR index which only takes into account the after-tax dividend amount.
Almost all indexes exist in multiple variants. However, which variant is considered “the index” may differ between indexes. Traditionally, “the S&P 500” is the PR variant; on the other hand, “the MSCI World” normally will refer to the TRN version.
In practice, the difference between index funds with and without dividends will often not matter that much. In many cases, investment companies will provide automated reinvestment of dividends: Whenever a fund pays a dividend, they will automatically use this money to buy new shares in the fund. This happens on a different level, though, outside of the fund.