When you cast a spell with targets, you choose those targets at cast time (CR 601.2c). Once the spell is on the stack, you generally cannot change its targets except by using a special effect like Fateseal, Redirect, or an ability that explicitly says 'change the target of target spell.'
If a target becomes illegal before the spell resolves — for example, the creature you targeted becomes hexproof or leaves the battlefield — you do not get to pick a new target. Instead, the game checks legality at resolution (CR 608.2b). If all targets are illegal at that point, the spell is countered by the rules and put into the graveyard without effect. If at least one target is still legal, the spell resolves but only affects the legal targets.
There is one narrow window where you can change targets yourself: if you have an effect that explicitly allows it, such as the spell Deflection or a copy effect. Outside of those, you are locked into the targets chosen on cast.
Concrete example: You cast Lightning Bolt targeting your opponent's 1/1 creature. In response, your opponent casts Giant Growth, making it a 4/4 — this doesn't make the target illegal, so the Bolt still resolves and destroys it. But if instead they blinked the creature out with Ephemerate, the creature is no longer on the battlefield when Bolt tries to resolve, so Bolt is countered by the rules and deals no damage. You never had the option to redirect it to a new target.
Key rules references: CR 601.2c (choosing targets on cast), CR 608.2b (checking target legality on resolution), CR 114.4 (illegal targets at resolution).
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.