How do these switches work?
They are called "momentary push-buttons" and sometimes they are latching types that appear to return to the same position but they mechanically latch the push-action so that (say) a light comes on and stays on then, when you press it again the light goes off and stays off.

Sometimes this is achieved with a non-latching push-button and some electronics that "latches" the press and does the reverse when the button is pressed again.

If you want a mechanical explanation then maybe this is not the site to expect an answer.