Button that increments a counter
Your code, simplified, is:

void loop()
    int a;
    a += 1;
}


The problem here is that, by putting the declaration of your counter variable within the loop() function, you've made it local to that function. Every time loop() is called, a new variable a is created, initialized to zero, and then incremented.

You want to move the declaration outside of loop(), creating a global variable that will remain in existence and maintain its value after loop() exits, so that the value is still there when loop() is called again:

int a = 0;
void loop() {
    a += 1;
}


(This could also be done with a static variable, but that's probably beyond the scope of this question.)