I think many manufacturers consider the guns sent out and transferred to sales reps as used when they get them back. They then discount them when they move them out into the retail market. Some do refurb work on those that may need it and some don't. Trust me they can be kind of shop worn going to shows, shown to wholesalers and retailers. Some of those guns can go to matches or be sent to reviewers and writer so they have been fired. Each manufactures have policies on how they deal with those firearms. Some allow the sales reps to sell them on their own, some take them back for a refresh and some take them back an just sell them as is at a nice discount. Some manufactures will give a warranty or a modified warranty and others treat them as an "as is sale". Like many retailers treat shelf guns by giving a discount for shop wear even if it is minor most manufacturer treat their sample demo guns as shop worn.
Ifa firearm is returned for warranty work by a final purchaser the firearm will be fixed and returned. If beyond repair the owner will get a replacement. I don't know how manufacturers deal with firearms that they determined were beyond repair. I would be surprised they would be marked and sold as used because the liability would be huge.
If a firearm goes out to a wholesaler or retailer and it has a blemish or is damaged in shipping. Those guns go back and are often replaced wu=ith a different firearm. Those I suspect are referred if possible and do get marked as used and sold by the manufacturer as used like Beretta with their "Y" guns and Smith & Wesson with their "U" guns
When it comes to DEMO guns, sample guns, guns returned by dealers due to shipping damages or blemishes, refurbished guns, etc, buyer beware. You will want to know the rules of game before you plunk down your dollars.