These are countermeasures to prevent a weapon system with guided missiles to lock on the helicopter. These are used by MANPADS and helicopters with weapon slot five. After firing flares the helicopter is safe for at least six seconds.
Additionally, this can be used to deflect incoming missiles. There is only a certain chance that it’s successful.
After you run out of flares they will reload in the air.