https://en.wikipedia.org/wiki/Identification_friend_or_foeHistory
With the successful deployment of radar systems for air defence during World War II, combatants were immediately confronted with the difficulty of distinguishing friendly aircraft from hostile ones; by that time, aircraft were flown at high speed and altitude, making visual identification impossible, and the targets showed up as featureless blips on the radar screen. This led to incidents such as the "battle of Barking Creek", over Britain, and the "air attack on the fortress of Koepenick", over Germany.
IR guided missiles have narrow field of view with wavelength of 80 nm to 1 mm. Narrow field of view gives it the ability to sense a heat source that is off the center line, lock it and follow it. That is the reason why flares are used to distract IR missiles, they produce greater heat making it a more attractive target.I have another question::
Why dont IR missiles head to sun?
How can missiles distinguish sun from other source of IR?