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?
Besides what the other user said, they recently made it a requirement for accredited phone services that they destroy any samsung phones along with their data, that they receive for servicing, if they have found that the user has done "unauthorized servicing" on it.
This is the next step after making the phones practically impossible to be disassembled, which they have done years ago.
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.
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.