I read on the internet that legacy is good for up to 2 operating systems and UEFI can allow more than 3 operating systems
That's absolutely rubbish. You can install any number of OSes as long as you have enough disk space. For example one guy actually did try to install 145 operating systems in a single PC on a BIOS system.
Someone who wrote that thinks that in legacy mode you can only boot from an MBR drive (actually wrong, see later), and MBR has a limit number of partition entries so you can only have 2 OSes. But the limit is actually 4 so you can already install 4 OSes to begin with if you created 4 primary partitions. You can also create 3 primary + 1 extended partitions to have more logical partitions inside the extended one. There's no limit in the number of logical partitions. Booting from a logical partition is a little bit trickier from the boot loader's side of view but that's not something we need to care about.
Linux has always been able to boot from logical partitions, and contrary to popular belief Windows version that use NT6.0+ boot loaders (i.e. Vista and up) can, too. Windows XP uses NT5.2 boot loader and can only boot from a primary partition
You can even install multiple OSes into a single partition. The most obvious example is DOS and Windows in the same volume. IIRC it was also possible to install multiple Windows to different folders in a partition. Or you can boot from disk images. Linux boot loaders has always been able to do that. Windows Vista and up can also be installed into VHD or VHDX image files. In the past there was wubi for installing Ubuntu into the same system partition as Windows to avoid re-partitioning the drive
Another way is to boot a GPT disk in BIOS mode in order to have more primary partitions. Many people think that UEFI requires GPT and BIOS requires MBR but those terms are orthogonal. UEFI and BIOS are different system firmware types whereas GPT and MBR are disk formats. "Legacy" here means BIOS mode and the BIOS doesn't care anything about the system loading process. It doesn't mind whatever hard drive you have, which format it's in and how many OSes you install. The BIOS simply loads the boot loader from the first sector of the boot device and run that. So it's completely fine to boot a GPT drive (which allows for unlimited number of partitions) with BIOS as long as the boot loader is capable of "understanding" GPT drives.
Linux boot loaders have that capability. See Is it possible to boot Linux from a GPT disk on a BIOS system?. Windows can also be installed into a GPT disk in BIOS mode by installing a software UEFI like DUET, or by installing to a VHD/VHDX image on the GPT disk as mentioned above. See Is there any way to boot Windows 7/8 using BIOS on GPT?
See also How many Operating Systems allowed in a single computer