Yeah I don't understand why Apple would even know my iPhone passcode.
I always assumed it stayed on the device.
It does stay on the device; the iPhone passcode is entered and authenticated locally, then the iPhone authorizes the AppleID password change since you're "authentic."