The bullet rifling marks are cataloged, and the shell casing firing pin and extraction marks are cataloged.
Sometimes at a shooting all one has to go on are spent shell casings, and extractor marks and/or firing pin marks have been enough to provide a match to a particular weapon.
But again, the marks left when new are almost never close to the marks left after years of use. Ballistics matching are usually only effective when there are few rounds between the test round and the crime scene round.
Or just change out the barrel and extractor and voila! Your handgun's 'ballistic fingerprint' is completely different. And since getting a barrel and extractor through the mail doesn't require an FFL, and these things are not difficult to change out (barrel very easy, extractor requires a little skill)...
Yet another waste of taxpayer money by the nanny.gov!