Both chaff & flares are defensive countermeasures deployed by using navy aircraft. The cause is to confuse radar-guided or infrared-guided anti-plane missiles fired so that they may want to be diverted.
The Chaff is composed of many small aluminium or zinc lined fibres saved on-board the plane in tubes. In case the plane feels threatened by means of any radar monitoring missiles, chaff is ejected into the turbulent wake of air at the back of the plane.
Flares on being fired grant an alternate strong IR (Infrared) source to heat-seeking anti-air missiles. Thus they are lured away from the aircraft.