Karl Marx quote on the right to keep and bear arms only applies to the proletariat. If you are a programmer and own the means of production (your laptop), you are not proletariat. All socialist and communist countries have strict gun control.
If you own AWS or GCP or Azure is a better example of owning means of production. A laptop cannot make you enough money to live by means of renting it out.
If you work for a living without owning the means of production and receiving the fruits of your labour, you are part of the proletariat.
If you own the means of production and receive the full fruits of your labour, you are part of the bourgeoisie.
Self employed programmers are bourgeoisie, employed ones are not. And of those that are part of the bourgeoisie, there are levels and not all of them are bad (even in the scope of socialist theory).
- The petite bourgeoisie are your small self employed shopkeepers, artisans, and tradesmen. These are the people who live by their own means and without exploiting anyone else's labour. Rising the proletariat to this level is the entire point of socialism.
- The moyenne bourgeoisie maintain largely the same lifestyle as the petite bourgeoisie but with strong financial establishment. They are effectively the upper end of the petite bourgeoisie and whether they are considered part of the problem or part of the end goal depends almost entirely on whether they are supported solely by their own labour or if they are unduly exploiting the labour of others. This class may lend money in some capacity however normally if they are doing so, they are doing it collectively.
- The grand bourgeoisie are largely where the problems with the bourgeoisie begin. These people have an established financial status from a few generations of wealth. This class is the one running larger businesses and their wealth is almost entirely derived from the work of others rather than their own.
- The haute bourgeoisie are the "true" bourgeoisie. You can only make it to this class through generations of wealth aggregation (unless you ride an industrial revolution) and once you are here, it is almost impossible to lose your financial status regardless of spending or financial failings. These are the eternally rich and their existence is only sustained by exploiting the labour of others.
Socialist theory considers the petite and moyenne bourgeoisie to be the "end goal" for society. They are nearly entirely sustained by their own labour and may use their excess funds to invest in the community (normally with some expectation of return but not any life sustaining amount). Marx warned that through the natural progression of capitalist society, these classes (primarily the petite but also the moyenne in some capacity) would wither while the wealth collected in the hands of the grand and haute bourgeoisie.
---
Additionally, many socialist and communist nations have strict gun control not because they are socialist or communist, but because they are authoritarian. Gun control is a sign of authoritarianism more than anything else and any nation that falls towards it is going to see the population disarmed.