The lens registers itself to the camera, and the camera allows for 20 unique lenses and lens+TC combinations. The teleconverters log themselves too so that the camera knows that you have both a TC and lens, making that an unique entry in your adjustment list.
What the camera doesn't do is log serial numbers. So if you have 2 of the same lens, they will share the same AFMA values. If you have a 100-400 and a 2xIII, you can have 2 values stored, one for the lens, and one for the lens+TC.
The same way the exif data on your images show the lens that was used, the camera uses that data for this AFMA registry in the camera itself.
It depends on the camera. The 5DIV can MFA 40 lenses and uses the serial number to register the lens. Evidently, you can still only register one model of the lens though. Not sure why as MFA displays the S/N so why not use that?

