Why does one gets executed if he leaves Islam? Is this authentic?

This exists in Islamic narrations
It does not apply in a non Muslim state
Also it is being reviewed by scholars on whether it applies today, since it was the case when those leaving Islam became direct enemies