C2 runs all events top to bottom. If you have multiple events with the 'object clicked' condition, those will both be run immediately one after another. So what happens is this:
User clicks object
C2 halts processing the rest of the event sheet and immediately runs mouse clicked trigger events
Event 3 is run - buttonokclicked=0, C2 sets it to 1.
Event 4 is run immediately after - buttonokclicked=1 (as it was set to 1 in the event preceeding it), so event 4's actions are run, setting buttonokclicked to 2.
What you need to do is either of the two things suggested to you:
On clicked object
(Subevent) if buttonokclicked=1, set buttonokclicked to 2
(Subevent) if buttonokclicked=0, set buttonokclicked to 1
Or
On clicked object
(Subevent) if buttonokclicked=0, set buttonokclicked to 1
(Subevent) else/if buttonokclicked=1, set buttonokclicked to 2
Either of those should work.