The Montana law employs a legal principle known as anti-commandeering or a “refusal to cooperate with officers of the Union,” as James Madison put it in Federalist #46.
https://tenthamendmentcenter.com/2022/04/04/how-montanas-2nd-amendment-protection-law-can-help-undermine-new-atf-regulations/