Encryption is a very easy copy paste of programs and Is free, guns are a complex physical device that cost money and must be manufactured elsewhere and distributed to sellers. There's a significant level in effective ability to use them.
But yes, it is similar. Distribution is so widespread that illigalization doesn't affect those who don't follow the law.