Why did mammals evolve to have two testes?
EvoDevo is not my field, but I will try to give you some pointers.

Mammals as vertebrates, start out as fertilized oocytes, transform into a rapidly dividing lump of cells with eventual polarity through numerous gradients of numerous chemical messengers, and form a neural tube.
The forming body is ever more segmented through the use of gradients and thresholds (see french flag model) and (dorsoventral) axial symmetry is maintained throughout development, and as such two testes represent the default development.

Therefore, it may be more interesting to ask for singular organs which require more information, and thus maintenance throughout evolution of this information. But when considering the energy requirements, the need for synchronization, the need for a separate blood supply and thus the introduction of additional faults, it is easy to see why we only have one heart.


Wikipedia; author: Zephyris, title: "The first few weeks of embryogenesis in humans", DOR: 25/09/2012

See: 


Inversion
Evolutionary developmental biology


I hope this helps as a starting point.