Actually, I don’t think it is as simply as you imply. My daughter had an iPhone here on a weekend and her little girl got hold of it and started punching buttons and accidentally locked it.
After a couple of hours on the phone with Apple support it basically ended up that if the phone were completely erased and reset, it may be possible to get into it, and that wasn’t a sure thing. The damned thing only gave you a very few tries at the code and with each successive try, the time period between times it would allow you to try again increased almost exponentially. After about three or four tries it would lock you out basically forever.
My daughter only got into it several hours later when she brought up the code screen and asked her three year old to show her what she punched. She pointed to the “5” and nothing else. Daughter tried 5555 - and that was it!
Some of the newest phones are now shipping with integrated fingerprint scanners.