In addition, you can easily fix it using other methods, such as using iTunes:
If you've synced your device with iTunes, you can restore your device. This will remove the device and its password.
1. Connect your device to the computer you are syncing.
2. Open iTunes. If you are asked for a password, try another computer that is synced with it, or use recovery mode.
3. Wait for iTunes to sync your device and back it up.
4. After the synchronization and backup are complete, click "Restore [your device]".
Using iCloud or adopting recovery mode is a common solution.