They allow side loading on macOS because the horse left the barn decades ago. They cannot enforce it for an OS that was designed originally in the 1990’s as NeXTStep. This kind of thing has to be enforced from the beginning to avoid breaking everything that exists today. IOS and its derivations were written from the ground up with this kind of security in mind. MacOS is nice, but it is a far bigger security risk than iOS, something Apple can mitigate such as asking apps to sandbox, but they cannot force them. Nor can Apple enforce no direct interapplication communication, something that’s forbidden in iOS where Apple spent years inventing mechanisms that avoid that, but go through the operating system to accomplish things that resemble that.
The biggest security hole in macOS is allowing unfettered access to the file system where anyone can muck with the key system files as much as they want given root privileges. They cannot take away rooting through Terminal that has existed as long as there has been Unix, while iOS blocks that ability beyond actual jailbreaking. MacOS is just a different beast they cannot pull back in time to revamp to their iOS security standards. I’ve said this many times. If Apple could have done it all over again, macOS’s security would look very much like iOS, but they can’t. It would be like resetting macOS back to square one with no apps available, something they can’t do without essentially killing the Mac.