It's legal because the government allows it. How else would it work?
Thanks, Captain Obvious. ;) the underlying question was why (although I used the word how and that’s on me).