Think about how events run. You have two trigger events with the same trigger condition (v is pressed). They can't run at the same time, so one is running directly after the other. Let's assume they are running in the same order as the event sheet (doesn't really matter):
condition: when v is pressed, if foo is 0:
action: set layout scale to A, and set foo to 1
event 2: when v is pressed, if foo is 1 (which it is now, because you just set it with the previous event):
action: set layout scale to B, and set foo to 0
See? When you press V, you are running both events one right after the other, and ending up right back where you started. That's why it works when you change one of the keys: now, only one event is being triggered, and the toggle works as intended.
Hope that helps.