At one time it was a Federal law, not sure if it is now.
It was a response to the Texas Tower shooter (Whitman?)
could be a law, don’t remember one, but, hey, no reason why I should