Every single country on Earth has these same rules.
It is a core characteristic of a nation that it is able, if it chooses, to inspect every single person and item entering it.
Even countries with open borders reserve the right, and have often exercised that right, to close their borders and enforce strict customs, immigration, and security laws.
It doesn't matter where. Europe, Asia, Africa, "good" countries, "bad" countries-- if you cross their border you can be compelled to unlock your phone.
If you think you live in a country that cannot do so, you are wrong. The only differentiating characteristic among all nations is the nature of the reaction if you refuse to comply.