The volume which comes out of speakers and into your ears is dependent on many different things. Some that come to mind are the sensitivity and impedance of the speaker drivers, the amplifier in the earbuds and the fit over/in the ear.
They are most likely just setting a toggle at a percentage of maximum volume level. The phone has no way of knowing what the sound pressure is at your eardrums.
You can rest easy knowing that you can ignore the warning if you think it isn't loud enough with the caveat that you could be damaging your hearing over time.
It could make a useful guess based on device identifiers. Or it could make a useless guess based on industry averages or some random device an engineer had on their desk one day. It clearly does one or the other, the question is which. Useful or useless?
Occam's razor says they are not going to keep a list of all devices and their configurations including types of ear pieces and their sound pressure level output at each volume setting when they could just say if (volume > .75){ warning();} and call it a day. There is no benefit to going above and beyond in this case -- they just need to say they warned people.
They are most likely just setting a toggle at a percentage of maximum volume level. The phone has no way of knowing what the sound pressure is at your eardrums.
You can rest easy knowing that you can ignore the warning if you think it isn't loud enough with the caveat that you could be damaging your hearing over time.