If a spell doesn't specify, targeting happens at the end only
An official Sage Advice ruling is applicable:
You choose the targets of a spell when you complete casting a spell, not when
you start.
The context for that ruling was a 1-action cast time which became 2-round, but it's hard to see how one could follow this ruling for Slow but not for spells which naturally have a longer cast time.
If a spellcaster is affected by slow and takes two turns
to finish casting a spell, what happens if their target has
moved out of range or out of sight?
Some spells make exceptions to that rule
Some spells do specify that you need to be in contact with the target for the entire cast time, e.g. Identify.
You choose one object that you must touch throughout the casting of the spell...If you instead touch a creature throughout the casting, you learn what spells, if any, are currently affecting it.
Or Teleportation Circle (10 mins, range: 10 feet):
As you cast the spell, you draw a 10-foot-diameter circle on the ground inscribed with sigils that link your location ...
So clearly this isn't one you can cast while fleeing from pursuers, and given the 10 ft range, the circle on the ground is the spell's official "target".
House rules for specific spells?
As always, a DM can override RAW and decide that any given spell works differently in their world, e.g. deciding that Prayer of Healing does gradual healing to the chosen targets over time, rather than building up energy in the caster's mind / around their body, to eventually be released in a burst.
But note that interrupting a long cast time does not cost the spell slot, and has zero effect. You can abandon (or lose) your concentration on Prayer of Healing at any time without losing your spell slot, so it's narratively problematic for it to do partial healing. If you do really want to restrict PoH, you could say that magical energy starts to build up in the bodies of the targets, but dissipates if the casting isn't finished.
As @DaleM points out in a 2020 answer on a duplicate(?) question, Does casting a spell with a long casting time require the target to stay in range and line of sight the whole time? (which disagrees with his 2016 answer here), this means RAW you could have someone teleport you near the end of a long cast time, for example of a spell like Hallow (24h cast time, You touch a point and infuse an area around it with holy (or unholy) power). It seems entirely reasonable for a DM to decide that the cast time of Hallow must be spent in the target location, for example to burn the incense there and dab the oil around.
But a very reasonable choice for allowing this is Tsunami, 1 minute cast time, A wall of water springs into existence at a point you choose within range. If you were hidden, or walking towards a fight during the 1 minute cast time, and only stepped out from behind cover as you finish casting, that's a fun way to kick things off.
Tsunami seems reasonable to me because the spell creates an effect that isn't really tied to that location, it just happens to be there instead of somewhere else. (Just to be clear, that's pure narrative justification, nothing in the rules makes that distinction. This part of my answer is separate from the rules question.)