This is a problem because, when batteries are left in a toy for years, even after they are dead, they start to leak battery acid which corrodes the contacts. You can tell when this has happened because the contacts look bumpy and green.
To fix this, buy a bottle of CLR (stands for Calcium Lime Remover), which you can get at most hardware stores.
Follow the instructions on the bottle, and rub the CLR on the contacts until they clean up.
If you want a more aggressive solution, buy some fine grit sandpaper, and sand the terminals clean.