How does the Master Boot Record (MBR) change? I can not figure out if there is an MBR specific to Linux-based operating systems, or does each operating system have a different MBR? How do I compare MBRs of operating systems? And if I write one with C for Ubuntu, will it work for other distributions as well?
If an MBR is always cross-platform, does mean that it will work on both Unix-like systems and Windows for example? And if not, what's the difference between an MBR for Windows and MBR for Unix?
In "idealistic theory", for dual boot scenarios, the MBR contains a "Boot Manager" that does things like determine which partitions are bootable, selects one (possibly by offering the user a menu to choose from), loads the selected partition's first sector (the selected operating system's boot sector) and passes control to it.
In this case, the MBR (and other associated code in the first track of the disk) is owned by a third-party utility that does not belong to any OS; and no OS should ever be allowed to touch/modify the MBR (or any other data that is before the start of the first partition).
However, in practice often people only install one OS, and for convenience OS installers provide their own MBR (so that people don't need to worry about installing a third-party utility); and almost every OS has nasty/egotistical "we only care about ourselves and/or want to be in control of any other OS you install" tendencies. This led to operating systems ignoring common sense and trashing each other and/or providing their own "anti-competitive" alternatives for dual-boot scenarios (GRUB and "boot.ini" on Windows).
This nasty nonsense became significantly worse (for users) when manufacturers/firmware started caring about security. The plan was for all code used during boot (including firmware, MBR and the operating system's boot loader) to be "measured" (checksummed using fancy cryptography built into a TPM chip) so that an OS (and other software - e.g., "remote attestation") can detect if malware had tampered with any of the code that an operating system depended on (because that "fancy checksum" would be different).
This means that if you install a second OS (corrupting/modifying the MBR of an existing OS), you change that "fancy checksum" and break the original operating system's identity, so after you fix the damage and get the original OS to boot again various other things (that depended on the "fancy checksum") remain broken.
Fortunately, UEFI mostly fixed this by taking on the role of "boot manager" (and deprecating the MBR completely), where (if multiple operating systems are installed) the firmware uses "UEFI variables" to determine which one gets booted, and each operating system can have its own different boot loaders in the UEFI system partition without conflict.
Sadly, the nasty/egotistical "we only care about ourselves and want to be in control" tendencies remain and operating systems are trying to find alternative ways to ruin everything (SecureBoot key management, using GRUB as a shim so that different operating systems can fight for control of GRUB's configuration, etc.).
How does the Master Boot Record (MBR) change?
The MBR doesn't change unless you install an OS. When you do install an OS, the MBR may or may not change depending on the OS installer and (in some cases) what you tell the OS installer to do.
I can not figure out if there is an MBR specific to Linux-based operating systems, or does each operating system have a different MBR?
Linux (the kernel) defines a "Linux boot protocol" which allows anyone to write a compatible boot loader. For booting from BIOS; there were 3 common boot loaders (LILO, GRUB and SYSLINUX); but most Linux-based operating systems gravitated towards GRUB, and most OS installers for Linux-based operating systems tended to install GRUB in the MBR as "boot manager plus boot loader".
I want to know if an MBR is always cross-platform, means that it will work on both Unix-like systems and Windows for example. And If not, I want to know what's the difference between an MBR for Windows and MBR for Unix.
Sadly, no - the MBR should be "OS neutral/cross-platform" (and can be in some cases - e.g., if the user doesn't mind installing LILO or GRUB in its own partition and if the OS installer supports that), but mostly isn't. If you want to write your own MBR then you'll probably need to deal with a specific operating system's failure to cooperate with other operating systems.