These are dumb batteries, not smart batteries that can report remaining capacity, so the firmware in the device has to estimate remaining capacity. It can only do that accurately if it knows the exact battery used. If you substitute a different battery, the firmware will not know the remaining capacity accurately, and won't work properly. Thus it's very important to use the correct Z55H battery.
p.s. This may be why there are so many reported XM4 battery problems. Reports indicate that Sony substituted some different batteries at the beginning of production when it could not get enough Z55H batteries, and the firmware does not work properly with those batteries over the long term, resulting in premature failure, often in only one earbud.