You can *be* whatever you want, you just can't practice openly.
The same is true of religion, you can hold whatever beliefs you like but you can't practice or display them openly while you are in KSA.
You also cannot consume alcohol or pork.
All of these things are outlawed by their religion.
You could go to Thailand instead, LGBTQ+ as well as alcohol and pork are all commonplace there. And yet, just like Saudi if you were to insult their religion or their royal family you could still face some severe punishments.
There are actually a lot of countries in the world where homosexuality is still illegal with varying levels of enforcement/punishment all the way up to death.
In Saudi it's also illegal to engage in heterosexual activity outside of marriage too. If you visit there with your boyfriend or girlfriend you have to book two hotel rooms and abstain from having sex while you're there (although you probably wouldn't be caught in the privacy of your hotel room and the hotel staff wouldn't report you). If you visit there alone as a gay man what do you think is going to happen? How would they even know that you were gay? You wouldn't be going there to find a date or a hookup any more than a straight man would, you'd have noone to engage in any sexual activity with. Everyone is expected to dress conservatively and be respectful of local customs etc.