Probably a great decision, but why/how can it be decided at a local level by a mayor, instead of a federal level?
I don’t think it would be a federal concern, but a state one.
However, in this case it’s because NYC law is typically allowed under NY state law to be stronger (but not weaker) than any corresponding state law.
why: because the federal level is not doing it
how: by declaring it a law in that area
Any jurisdiction can pass a law unless there's a law against doing so.
For example, you couldn't do this in Massachusetts. A city would first have to petition the state for a new law allowing the city to pass such a local law.