There aren't any rules specifically with scales to this matter.
However, it just takes instinct. The people who improvise like this in such a way that they literally create new scales as they play; have been playing for many years and can hear if it will sound right before they even play it!
Using a V chord in this example but can apply to any chord,
It is common that some players will be playing a scale over say.... a V7 chord in some progression and decide to switch from the scale to a V7 arpeggio or V altered arpeggio and add a couple notes into their improvisation. Which combines the scale with the V arpeggio.
There are rules however to adding in notes. To understand them all you have to understand Chord Theory since adding in extra notes into your scale will depend on what type of chord is being played whilst improvising.
Simple example to applying chord theory to improvisation, if the chord in which you are improvising over is a minor (has a flattened third) you're not going to add in a natural third to the scale. Because it would sound horrible!! (unless of course you like the tension)
As for the progression. There aren't any rules to tell you that the AMaj should be a Amin chord. There are recommendations to basic structure, but no rules to say it doesn't sound nice either.
Always remember the most important rule in music:
If it sounds good, it IS good - Duke Ellington
Hope this helps! :)