An index fund is a stock which owns a basket of stocks in a particular index. The most famous index fund by far is the Vanguard S&P 500. This holds the best 500 companies as rated by S&P at any given time.
When you want to put money into an index fund, it’s just like buying a stock. You buy the index fund.
When you want to take money out of an index fund, you just sell the index fund, as you would a stock.
Note: index funds do not function like bank deposits, which is why you cay be having difficulties here. You can put money into a bank account and take it out of a bank account freely. Buy with index funds, you are actually buying a stock which owns a basket of stocks.
You can learn more about index funds here: https://basic-capital.com/index-funds-explained/