@starwed has a great open-ended answer, but I wanted to provide some specific spells and counters:
This is causing me huge headaches anytime I place a spellcaster enemy in the game. At the moment, the enemy usually gets one spell off at best before being assaulted and constantly followed by the magus and unable to continue to cast properly.
So what spell are they getting off?
These are "bread and butter" spell caster spells to specifically avoid getting into melee.
If you get stuck in melee, a caster over 3rd level can usually survive one AoA. Especially with the Magus who is just making a regular attack. That regular attack will deal limited damage because they don't get to use Shocking Grasp with it. That means the concentration check is not an automatic fail.
Two other spells can help nullify the situation:
- Haste: I can run away from the Magus faster than he catch up
- Slow: again, much easier to get away