A defector is an individual who changes their allegiance from one government to another.
Such individuals will leave their original government's jurisdiction and begin to reside in an opposing one. This is usually due to a political or moral disagreement with a government or its policies that cannot be remedied. In most cases the two governments involved are enemies, or at a minimum have poor relations.
Admiral Alidar Jarok, a Romulan, defected to the Federation in 2366. He had done so believing that the Romulan government was establishing a secret base on Nelvana III as a prelude to an invasion. He believed that the war which would follow had the potential to destroy the Romulan Empire. He defected in order to provide the Federation with the information to prevent such a war. He did not realize that the information he had was disinformation fed to him by his government, which suspected that he might defect. Upon realizing this, he committed suicide. (TNG: "The Defector")
In 2349 Ensign Stefan DeSeve of Starfleet defected to the Romulans. He believed that the Romulans had clear moral values and an absolute certainty about what was right and wrong. As the years passed, he grew disillusioned with such a philosophy and returned to the Federation in 2369 to convey a message from the Romulan underground movement. (TNG: "Face of the Enemy")
In 2374, Quark misremembered the word deflector, briefly causing him to suggest that the self-replicating mines guarding the wormhole were going to be disabled with the help of a defector. (DS9: "Behind the Lines")
In 2375, the sixth clone of Weyoun brought Odo to a barren moon in Cardassian space and announced his intention to defect. Weyoun stated that he felt the Dominion's war against the Federation and its allies was wrong, and holding such a view put him at risk of being killed. He offered Odo all the information he had on The Dominion in exchange for being evacuated to the Federation. Though Odo did attempt to do that, Jem'Hadar forces dispatched by Damar and the seventh clone of Weyoun prevented it. Weyoun 6 eventually made use of his termination implant to prevent Odo's death. (DS9: "Treachery, Faith and the Great River")
Also in 2375, Kashyk of the Devore Imperium appeared to defect to the starship USS Voyager in the Delta Quadrant in order to assist Captain Janeway with transporting her telepathic crew members and passengers through his government's space. His defection, however, was a ruse designed to expose and capture the telepaths and Voyager. Kashyk, however, was himself double-crossed by Janeway, and his ruse failed. (VOY: "Counterpoint")