The idea behind states is that the country is made up of a union of independent states with a federal government which serves to mediate between the states and make sure they do not overstep on things like basics rights and deal with the international issues. Technically this is absolutely in the power of a state, practically speaking they might as well try and ban air from ND from crossing their boarder.
But Montana is perfectly aware that they can not actually ban TikTok or any other app on their own.