Why do some fighter jets have two pilots while others have only one?
All fighter aircraft have one pilot, though some have two crew members.

The backseat crew member is not a pilot, but often either a Radar Intercept Officer (US Navy), Navigator/Weapon Systems Officer (USAF, IDF), or Flight instructor.

Though not fighter aircraft, I believe that the SR-71 backseat crewmember operated the reconnaissance equipment as the single crewmember on the U2 was often overloaded with keeping the thing in the coffin corner and operating the reconnaissance equipment. Jan and Habu mention in the comments that the SR-71 backseat crew member was also the navigator and operated the ECM equipment. Additional comments mention that the B-1B consists of four crew members: two pilots, an OSO (offensive systems operator), and a DSO (defensive systems operator). The B2  has two crew members, both pilots, and while one is flying the other can rest, navigate, or operate the weapons system. Thanks to Jan, Habu, and Joel for comments and clarifications!