Is it? Android already disables sideloading by default, requires each source to ask for permission, and prompts the user before each install. How does Samsung's additional setting improve security?
If you mean the S24, the equivalent from Sony would be the Xperia 5 V. Has audio jack and sd card compared to the S24, Sony batteries last 2 days even after several years of use thanks to excellent optimization and battery care, there's almost zero bloat. On the downside it will only get 2 years of upgrades (until the end of 2025). Also you can't unlock the bootloader on US models if that's something you care about.
I think the Pixel Fold might be the best option for a foldable phone, because (just like all other Pixels) you can flash it with a private, secure, open-source ROM like GrapheneOS.
Motorola makes the clamshell fold. Seems to be a lot better value as well. Can't speak to all the bloatware and other anti-consumer shitfuckery because I've never seen a reviewer that thinks it's important.