There are several issues at play here - IANAL, but this is my understanding:
In general, the constitution defines what are state and federal powers. More specifically, it lists federal powers and any other powers are up to the state to define. For cities - depends on the state constitution, but I have not heard of any state off hand where the state did not reserve the right to override a county or municipality.
Of course, where it grants citizens certain rights (“The state shall make no law…”, “a free press…”, etc.) then that guarantee applies to the whole country, including the states. (Didn’t always used to be so.)
So as an example - it is up to the state to define whether pot is legal or not. What the federal government has done is assert its power to regulate interstate commerce - you cannot take pot across state lines. They have twisted this with the argument - that the Supreme Court agreed to, decades ago - that to properly restrict the interstate traffic, they had the right to ban production trafficking and possession within a state also, since logically such activity would inevitably contribute to interstate trafficking. Apparently, the interstate commerce clause has been used to argue the feds can intrude on almost everything that is a state right if they can claim it is necessary to regulate interstate commerce. Or for example, an offense against the federal government - such as assault on a federal officer, different from assault in general, a state crime.
Plus, the feds cannot force a state or it’s law enforcement to act - directly. They can apply financial persuasion, positive or negative. But they cannot force the police of a state or city to enforce federal laws if the state chooses not to. The various states can “legalize” marijuana but as mentioned earlier, cannot change federal law. The feds can, however, decide to look the other way and not enforce the law. Generally, marijuana enforcement is a state crime where it is still illegal, so the federal effort is mostly spent chasing down traffickers and such.
What we do see is a “tolerant attitude”.
Another fun note - violating a state law and violating a federal law are two different crimes, even if it was one act. Therefore, you can be charged by both, double jeopardy is not applicable.