For a Glock, people that like to shoot lead bullets will buy an aftermarket barrel for this purpose. Or, they may buy a threaded barrel so they can use a suppressor. Still talking Glock here, you can buy conversion barrels that will allow you to shoot different calibers of ammo through the same gun.
On a rifle, I'm talking 10/22 Ruger here, many factory barrels are very accurate. Many of these barrels are taken off before a round is fired through them. Back when I could see, I had a factory barreled 10/22 with some trigger work and a good scope, and it would shoot one hole groups at 50 yards.
I have one now with a scope and a good trigger that will shoot much better that I'm capable of doing. But, I will admit that some of the tricked out 10/22's sure do look sweet.