The court viewed this as unconstitutional interference in the commerce between the origin and destination States, which seems correct on its face. There must be evidence of intent to distribute the firearms in the State where they are illegal. This case created a safe harbor for mere transport of goods between States.
Cannabis is different because it violates Federal law. It is technically illegal everywhere even though it is legal under State law in many locales. The Federal government has chosen to not enforce this law in States where it is legal, largely because enforcement could create a Constitutional case that could bring into question Federal authority to enact those and many other laws.