It’s hard to answer why without more information, but most likely one or more of the prerequisites for updating weren’t satisfied. To update over the air from the phone all of these requirements must be met:
- You need at least 10 GB of free storage for iOS 16 and later or 6 GB for iOS 15 or lower; more is better
- You must be connected to a Wi-Fi network (and not a personal hotspot)
- The phone must be charged to at least 50%, and preferably plugged in so it stays above 50% during the update
- The phone must not be in Low Power Mode
- The phone must not be connected through VPN, and it may be necessary to delete any VPN apps and VPN profiles
- The phone cannot be in Airplane mode and must have a cellular data connection
- You cannot still have a beta of a previous version installed on the phone
- You cannot have a previous version that was downloaded, but not installed - go to Settings/General/iPhone Storage to look; if you find an iOS installer, delete it
- If you have Update Automatically enabled the phone must be plugged in, locked and connected to Wi-Fi.
If you can't meet all of them you can still update using your computer:
Here are 2 links, choose the one for your computer.