Read this:
D3 (GPIO0) must be HIGH at boot, so your switch was probably connected across D3 and GND and closed at the time.
Pete.