This generally happens because the passcode was entered incorrectly too many times. It can be caused by a faulty touch screen, getting pressed inadvertently in your pocket, or just plain trying to remember your password. Once it is in this mode, with no more option for “wait X long to retry” your only option to get it working again is to [link|https://support.apple.com/en-us/HT204306|reset it using recovery mode and a computer with iTunes using this method].