Why has the A340 not been fitted with only three engines?
Because the third engine would need to be near on centerline. That means in the tail.

Putting the engine in the tail significantly changes its design requirements. 

Supporting an engine requires a lot of structural support. Then you need to run fuel to it. The effective height of the rudder is decreased. You probably need to switch over to a T-tail. The center of mass is also shifted which influences where the wings need to go.

In short, adding a single engine requires a redesign of the entire tail. While adding an engine to the wings is much simpler.