The idea of an index fund is that you neither buy nor sell. Just by sitting on your stock, you get average returns. There are a few exceptions: when someone invests in the fund, the fund has to invest their money, and vice versa when someone withdraws money from the fund.
When a company enters/leaves the index the fund is tracking, the fund has to buy/sell their shares.
When a company enters/leaves the index the fund is tracking, the fund has to buy/sell their shares.