Why can carriers limit unlocked iPhone hotspot/tethering? The answers here and here explain that carriers can tell an iPhone whether to allow tethering or use as a hotspot.
My question is why, on an unlocked phone, can they do that?
Has Apple simply colluded with a cellular service consortium to respect their wishes?
Or are there a means by which a cellular data provider can detect that data are being served to and from a different device through the iPhone bearing its SIM card?  (While possible without any countermeasures, AFAIK it would be trivial for the iPhone to obscure the fact that it is tethering.)
The main reason for this is that Apple works together with cell providers. Both have an interest in having the right products available for their customers.
It is of course trivial to say that the iPhone knows that it is tethering, as this is part of the functionality implemented on the iPhone. However, as you state: the main reason that providers know that you're tethering is simply that the phone tells them this. Often this is done by having ordinary data traffic to/from the phone pass via one APN, and tethered traffic pass via a different APN.
This allows cell providers to offer different service levels, transfer maximums, pricing, QoS, etc. on the two types of date.
However, it is not so that any tethering is not detectable without the iPhone explicitly telling the provider that tethering occurs. Cell providers have ways of detecting tethering that works in different ways – some more foolproof than others.
For example data packets on an IP network have a TTL value in their headers. Whenever the packet is routed from one network to another (for example from a laptop to a home router to a USB connection to your phone and to the cell providers network) then the TTL value is decreased by one at each &quot;hop&quot;. This is done to ensure that no packet can stay in the network indefinitely (i.e. due to loops, circular routing, or other problems) so when the TTL value reaches 0 it is discarded. A cell provider can use changes in this number as an indication of tethering happening.
Historically, tethering has been one of the reason why some have jailbroken their phones. Several types of add-ons exist that are intended for users to get tethering working (or bypass limits) where it previously wasn't possible. In some cases this could be breaking their agreements with their cell providers, in others not. This has been discussed for example here:
https://yalujailbreak.net/hotspot-tethering-app-iphone/
Additionally, some have created apps that allow for the same functionality without jailbreaks. For example take a look at this open source project:
https://github.com/rickyzhang82/tethering
Essentially they work by implementing a proxy server in an app on the phone. This allows other computers to connect to the proxy for data transfers (such as web browsing, downloading files, or whatever it might be) while the data transfers appear to have taken place on the phone itself.