You have to remember the code is executed from top to bottom.
In your case, when the var = "Follow", it is set to "Stay".
And right after, it testes if the var = "Stay" (which is true since we just changed it) and so it sets it to "Follow", but the testes are done and the code executes for another object.
By the way, you don't need the "For each object" in the top level event, this is implicit in C2, the conditions are tested for all instances of the object, and the sub-events will use the picked instances from the first event.
What you would need here is rather :
On shift Pressed
Object is overlapping Object2
..Local variable Temp = 0
..If Object variable = "Follow"
..If Temp = 0
..==>Set Temp to 1
..==>Set Object variable to "Stay"
..If Object variable = "Stay"
..If Temp = 0
..==>Set Temp to 1
..==>Set Object variable to "Follow"
Like in this capx.
You can see the actions are only applied to the instances picked in the top level event.
When you check for overlaping, it only picks the instances overlaping.
That's how events work.