Thomas Riker was created on a very hostile planet during an attempt to beam up William Riker in the narrow window that the planet's conditions allowed for transport. The transporter operator attempted to obtain a second transporter lock on Riker to ensure his safe retrieval, and the second transporter beam reflected back onto the planet, where "Thomas" Riker re-materialized. Thomas lived there for years, assuming that his shipmates thought him dead. He was rescued by the USS Enterprise, ironically by William Riker.
Unable to stomach serving on the same ship as his transporter double, he sought a position elsewhere in the Federation fleet.
Joining the Maquis
Disillusioned by his life in his own shadow, Thomas Riker eventually left Starfleet and joined the Maquis. As an exact duplicate of William Riker, his biometrics allowed him to penetrate the security around the USS Defiant at DS9. Once on board, he kidnapped Kira Nerys and faked a catastrophic system malfunction to steal the ship and take it into the Cardassian DMZ to attack a secret Obsidian Order shipyard. He was tracked down and captured by Gul Dukat and Benjamin Sisko, after which he was sent to a Cardassian prison, where he presumably died during the Dominion War.