In real life, United States presidential elections are held every four years. The first was held in 1788 (roughly) and as such the elections of recent times have been held in 1996, 2000, 2004, 2008, and 2012.
However, in The West Wing's President Bartlet was elected in 1998, and subsequent presidential elections depicted in the show take place in 2002 and 2006.
The obvious out-of-universe explanation is that Sorkin wanted the show to take place in (then) current day, and wanted Bartlet to be in the early part of his term at the beginning of the show. The show debuted in 1999, so it obviously wouldn't fit if he was elected in 1996 or 2000.
Has an in-universe explanation ever been given? I'm in the middle of Season 4, and the most recent real-life president I've heard mentioned was Richard Nixon. Did the Nixon presidency end differently than in real life, somehow prompting a constitutional change that shifted presidential elections by two years? Or was the first presidential election shifted by two years from real life in the show's continuity? Or did the writers just sweep this under the rug and never address it?