As others have stated, tandem cockpits have advantages in that they create more slender bodies and require minimal modifications from single seat variants. The twin-seat modification is not always an issue, as many airplanes are designed from the get-go as two seaters, such as the F-4, F-14
and F-15. F-15 single and twin seaters share the same canopy, the second seat and instrumentation is all the difference between single and twin seaters (I'll leave the F-15E Strike Eagle aside, it has many modifications in the cockpit and in the rest of the aircraft).
F-15C and D have different canopies and minor airframe differences, see https://images-na.ssl-images-amazon.com/images/I/81Otq1glyTL._AC_SL1500_.jpg
Most tandem airplanes have different front and rear cockpits, the pilot and co-pilot/RIO/WSO have almost wholly independent tasks. Many rear seats don't even have flight controls; even if they do, visibility is very limited in the back so rear seat pilots take over flying only to reduce fwd pilot fatigue (in cruise or loiter) or when the fwd pilot is incapacitated.
OTOH, side-by-side designs improve cooperation between pilots and make for more spacious and less fatiguing cockpits. In the Su-34 and B-2, there is enough space between the seats for one occupant to lie down and sleep/rest, a huge luxury. In addition to long range missions, many aircraft with side-by-side cockpits have low-level penetration as a mission. Low-and-fast missions require excellent cooperation between pilots as they are seconds from hitting the ground at any given time. The F-111, B-1, Su-24 and Su-34 have side-by-side cockpits also for this reason.
The single seat Ka-50 helicopter was sidelined/superseded by the side-by-side Ka-52 mainly because of the excessive workload on the single pilot. Russians had the Ka-50-2 tandem cockpit design ready (concept for a Turkish Army tender, rejected in favor of ex-USMC Cobras), but they still went ahead with developing the Ka-52, ostensibly to improve pilot coordination. However, most attack helicopters (Mi-24, Cobra, Apache, Mi-28 and others) have tandem cockpits, to present a smaller frontal target to ground fire, in addition to the usual aerodynamic concern.