My understanding is that most immutable distributions store the root filesystem in a read-only partition separate from userspace. If you want to install something that would modify this partition, it is applied temporarily until reboot. On reboot, the operating system attempts to resolve your changes, and if they break something it will reject them.
Each OS might implement immutability differently, but I believe that’s the general idea. macOS is another example of an immutable operating system, as of Big Sur.
Hmm… I didn’t know that. Thanks!