When you switched the phone off correctly, it knows that its power will be shut down shortly.
That means, all the applications and the operating system get the chance to save whatever needs to be saved and to go through their proper shut-down process.
Removing the battery without switching the phone off will immediately crash every running applications as well as the operating system(OS). It’s just like unplugging your system while it’s running. You can do it, but it’s not advice-able, a bad idea, though.
Another thing is that While switching off your device, the operating system will make sure that everything connected to the phone’s memory and external memory is properly and carefully closed.
If you remove the battery before switching off your phone, you may corrupt the memory which may lead to unexpected behaviour.
To summarise everything, Please always switch off your phone before removing the battery.