Why would a burglar who would probably face a few months prison carry a gun, for which just the possession will lead to 2 years inside ?

Burglars are not idiots.