It depends on the type of missile that was used and even on the upgrade status of the “seeker” component.
http://www.ausairpower.net/APA-Legacy-SAM-Upgrades.html#mozTocId532833
It depends upon a lot of things but mostly it depends upon geometry. Both the aircraft must be properly aligned. When the missile loses track on the first aircraft, the second aircraft must be in the seeker field of view or very close to that field of view. The seeker is not given unlimited authority to go find another target. It is constrained to try to re-acquire the original target not go off on some wild goose chase just looking for any old target.