Why was the A340 developed with four engines?
Hindsight is 20/20.

At that time, nobody could be sure the ETOPS rule would be extended the way it eventually was. The 1985 extension was a gift from the FAA to Boeing, so US carriers could use the Boeing 767 for transatlantic services. The 1989 extension to 180 minutes allowed them to cover all domestic routes with a single type when before they needed three-engined types (TriStar and DC-10) to fly to Hawaii.

Not everyone at that time was in favor of introducing ETOPS: McDonnel-Douglas said in 1984: 


  ETOPS "represents a 'totally new risk' that the industry has a limited capability to offset."


and


  "… the possible adverse consequences of premature extension of the operating limits can never be balanced by economic gain."


Especially Lufthansa had been sceptical of using two engines for long range and was a driver for the A340 development. Also, Airbus had experienced FAA chicanery before (remember that the A300 was banned for a while because of its slightly higher ground pressure loads). Airbus simply assumed that this kind of chicanery would be repeated when they went with a two-engined long range version.

That only changed when Boeing introduced the 777. Now Boeing was pressing for an ETOPS extension ("early ETOPS") and the FAA duly obliged. But that was in 1995, a full decade later and after Boeing had done extensive ground and in-flight testing, including running engines for a quarter of a million hours. ironically, the positive experience with the A320 in its first two years of operation helped to convince the sceptics of the merits of early ETOPS.