Just because a layer is invisible, doesn't mean that it isn't interactable. If the buttons are in the same place, then you are hitting both at the same time. You then end up with a classic toggle problem - If A then B, if B then A - Both will run, resulting in A.
Use else, or add the "layer is visible" condition to your button event.