I don’t think we can control how this works since Apple makes the code and policies on the back end.
As far as official documentation for this step, apple says just
To approve iCloud Keychain when you don’t have access to your other devices, follow the onscreen instructions to use your iCloud Security Code.
I think of this as a for, of two factor where they use the device passcode as the second factor instead of you accepting the push notification to another device to authorize.
When you reset all settings or restore a backup from iCloud (or set up a device as new), the Keychain / iCloud and local USB trust pairings are removed and you should be prompted to trust the Mac when it connects to your iPhone.
After the trust setting dialog pops up (if you are connected over USB), there is now a screen that asks you to enter your iCloud password to finish setting up the iOS device. I have not seen the follow on passcode/password page ever until today. In my case, it wanted the passcode on another iPad and not a Mac ( I have two iPads, an iPhone, Apple Watch, two Mac connected to my iCloud account as primary accounts / keychain sync enabled on all).
Enter Passcode for Other iPad
Access to your account is protected by the passcode for "iPad". Your passcode is encrypted and cannot be read by Apple.
In my case, the iPad in question is named iPad Air 2 and there's a blue link with the text "Forgot iPad Air 2 passcode?" Tapping that lets me select another device to enter a passcode. I then selected my Mac Pro and the text changes to:
Enter Mac Pro Password
Access to your account is protected by the password for "Mike's Mac Pro". Your passcode is encrypted and cannot be read by Apple.
I do have two step authentication enabled for my iCloud account so this seems a legitimate change that Apple has implemented recently to secure backups and/or joining a "new" device or OS to the keychain syncing / trust chain.
After entering the password, there was a long delay (the iPad screen went dark) and the next step was the iCloud Keychain dialog which also was slow to continue when I tapped that.