Unfortunately, in practice, Apple have proven to be entirely incompetent at achieving that protection. The App Store is 90%+ garbage and scams. It's completely unusable for any form of discovery. Even when you know exactly what app you're looking for, you have to wade through copycats, typo squatters, and even paid adverts trying to distract you from your search.
Sideloading is full of risks, and I don't love it. But it's at least a little bit of competition to push Apple towards make the App Store useful again.