i'm still not sure what a state machine does
Try drawing a picture, then. Draw a circle. In the circle, write the name of the state (buttonPressedOnce, buttonPressedTwice, etc.). Then, draw arrows between the circles. Above the arrow, write the action that causes a change of state (switch pressed, for example). Below the arrow, write what needs to be accomplished during the transition.
If you think about this, you could have sub states (lightsOn and lightsOff). Some states can only be reached when another state is current. So, while the state is buttonPressedTwice, the trigger to transition from one state to another can be that a certain amount of time has passed. After a while, you transition from lightsOff to lightsOn or from lightsOn to lightsOff.
Certain actions occur when the transition happens - the last time a transition occurred might be recorded. This is useful for measuring how long it has been since the last transition, which is the criteria for transitioning again.