A simple explanation could be:Preston was driven and watched from the very beginning by Dupont to stop the dose and start feeling so he can gain the trust of the resistance and lead to them as Dupont tells him at the end. With or without the gun swap he would not have been arrested before delivering the resistance.Another theory is:When Brandt takes Preston before Dupont (after Preston is seen crying because he was unable to stop Mary's execution), it is revealed that Brandt's weapons, not Preston's, were the ones used to kill the sweeper team in the Nethers. When Brandt thinks about this, he realizes that Preston must have switched guns with him, and we flashback to the scene in the industrial section of the Nethers, where Brandt offers Preston his gun to kill the sense offenders lined up against the wall. Since this sequence occurs after Preston massacres the sweepers to save the dog, people assume this is a major plot hole. And it is...but it was not intended to be.In the original script, the following is written:"And he flashes back:TO HIS CAR: The house in the zone burning in the background.BRANDT: Who will be left to watch...A beat. Then Preston hands Brandt his gun."It should be noted that excerpt has been taken from an early version of the script (the version in which Mary lives), but the idea is the same: the switch actually took place right before the first time Preston saves the dog from being killed.Further to previous answers, there are scenes and shots missing from the final cut of Equilibrium that would have explained the "gun swap" clearly. Unfortunately, they were left out for any number of reasons such as noticable camera shake, bad lighting/framing, lack of time/money etc. The "gun swap" plot point does actually work but now needs a little clarification. The tracking system used by Dupont's aid does not work by identifying a gun's specific location but by locating the specific gun that any Cleric is carrying at a given time. Within the the context of the film , the gun swap can be explained as follows:1) Preston kills the sweeper team in the nethers with his own gun.2) Later, when Brandt asks Preston to kill the assembled line of sense offenders, Preston hesitates and Brandt offers him his own gun. Taking it, Preston, (sensing an opportunity) swaps it with his own gun, giving Brandt the gun he used to kill the sweeper team.3) Later, when Brandt has brought Preston before Dupont, the gun that killed the sweepers is located on or about Brandt's person. Pulling the gun from his pocket and reading the serial code stamped on the bottom, Brandt realises that Preston has swapped the guns. Admitting this to Dupont, Preston interrupts by saying that the only reason Brandt has his gun is because Brandt took it from him when he arrested him. This alleviates Brandt's possession of Preston's gun by making it sound like it was Brandt who killed the sweeper team with his own gun. Unfortunately, Dupont never uses the tracking system to try and locate Brandt's gun, which is actually in Preston's possession and would therefore descredit Preston's explanation.4) However, Dupont isn't so easily duped as he is shown in his private ante-room at the climax of the film with Brandt next to him, leaning on the desk. This implies that Dupont had allowed Brandt to explain himself and then used the tracking system to locate Brandt's gun on Preston or that it was all part of a master plan and he was just playing along with Preston. It is now up to the viewer to decide which piece of exposition they like the most.5) Finally, all of this is somewhat moot, given that during the murder scene in the Nethers, Preston is using TWO guns to kill the guards. At no time do you see Preston handing more than one gun to Brandt. Preston hands Brandt a gun just before the sweeper team starts killing the dogs, and then he swaps a gun with him during the raid scene after the murders in the Nether have taken place. Assuming that the switch did take place between these two times, only one gun would have exchanged hands. When you factor this in, it becomes more than just a plot hole and branches into the realm of film goof.
It shows that the regime is rotten to the core and all about power rather than preventing violent emotions, Dupont's office is filled with illicit art, decoration etc and he quotes poetry to Preston in their final confrontation. Dupont (and by implication Brandt and the inner circle) is a hypocrite who breaks the society's own rules by committing 'sense' crime, whilst executing others for doing the same. Preston may suspect this all along as he notes Dupont's anger in a society where it is forbidden and his sliding his hand across the table in much the same way as Preston enjoys the sensation of running his hand along the handrail at the train station.