if you read it,
if background = 0 set background to 1
and then event 3 is true and it goes back to 0
So both event happens.
Also local variable are reset to there default value every time you read the subevent part they are into.
Your solution is to use a global variable, not a local. Just drag the declaration just before event 1.
And then event 1 before your subevents just do a
System: set background to 1-background
It will toggle between 0 and 1