Here's the relevant part of the spell rules, under standard actions:
Most spells require 1 standard action to cast. You can cast such a
spell either before or after you take a move action.
Most spells have a casting time of 1 standard action. A spell cast in
this manner immediately takes effect.
Many spells have a range of touch. To use these spells, you cast the
spell and then touch the subject. In the same round that you cast the
spell, you may also touch (or attempt to touch) as a free action. You
may take your move before casting the spell, after touching the
target, or between casting the spell and touching the target. You can
automatically touch one friend or use the spell on yourself, but to
touch an opponent, you must succeed on an attack roll.
Ranged Touch Spells in Combat: Some spells allow you to make a ranged
touch attack as part of the casting of the spell. These attacks are
made as part of the spell and do not require a separate action. Ranged
touch attacks provoke an attack of opportunity, even if the spell that
causes the attacks was cast defensively. Unless otherwise noted,
ranged touch attacks cannot be held until a later turn (see FAQ below
for more information.)
The part about casting, moving, and then having the spell take effect by touching is an exception that applies to touch spells. For other spells, they take effect immediately upon casting unless the spell says otherwise. If you want to cast Chain Lightning from a certain position, you have to move there first.
In fact, with touch spells you don't have to use them in the same round you cast them. You can hold the charge of the spell and use it in another round:
Holding the Charge: If you don't discharge the spell in the round when
you cast the spell, you can hold the charge indefinitely. You can
continue to make touch attacks round after round. If you touch
anything or anyone while holding a charge, even unintentionally, the
spell discharges. If you cast another spell, the touch spell
dissipates. You can touch one friend as a standard action or up to six
friends as a full-round action. Alternatively, you may make a normal
unarmed attack (or an attack with a natural weapon) while holding a
charge. In this case, you aren't considered armed and you provoke
attacks of opportunity as normal for the attack. If your unarmed
attack or natural weapon attack normally doesn't provoke attacks of
opportunity, neither does this attack. If the attack hits, you deal
normal damage for your unarmed attack or natural weapon and the spell
discharges. If the attack misses, you are still holding the charge.