WHEN United States Secretary of State James Baker III announced Friday the well-kept secret venue for the Middle East peace conference, a gasp of surprise arose from his audience: Why Madrid?Spanish officials are keeping quiet on the subject, generally restricting their comments to stating how honored Spain is to have its capital selected to host a conference whose concept it has long supported. But with Madrid hit by a wave of terrorist attacks - three car bombs exploded the day before the conference site was announced - some observers were astonished an event so sensitive and potentially a terrorist target would be held there. When Spanish officials expressed the government's determination to "do whatever we can to make the conference and the peace process a success," it can be assumed security is one thing they had in mind. Yet unofficially, and among Spanish observers, several reasons are cited for the choice. One is Spain's support for the United Nations coalition during the Gulf crisis, which pleased the US and the Israelis, yet was not so strong as to put off a country like Jordan, or the Palestinians. Although the only direct Spanish contribution to the war was three ships that never came close to combat, Spain did make its air bases available to American B-52 long-range bombers. Another reason Madrid was chosen had to do with Israel's desire to improve relations with Western Europe and the European Community. In that respect, an EC member's capital became more attractive than Lausanne, Switzerland, previously cited as a likely conference location. Spain also maintains close relations with the Arab world generally and with the Palestine Liberation Organization (PLO) in particular. But at the same time Spain has avoided cultivating the kind of high-profile image of a Palestinian sympathizer that French President Francois Mitterrand earned for France, for example, when he met with PLO leader Yasser Arafat in 1989. Spain has worked to build links with Israel since diplomatic relations between the two countries were reestablished in January 1986. Spanish Foreign Minister Francisco Fernandez-Ordez went to Israel in 1989, and Israeli Prime Minister Yitzhak Shamir visited Madrid in May of the same year. Spanish Premier Felipe Gonzalez Marquez plans a trip to Israel Nov. 22-23, while Spain's king and queen plan to follow with their own trip sometime after Mr. Gonzalez. Some observers even note Spain's attraction as a country of three cultures: Christian, Muslim, and Jewish. Next year's quincentennial commemoration of Christopher Columbus's 1492 discovery of the New World will also mark the year Muslims and Jews were expelled from Spain. But some observers say the country remains a natural meeting ground for the three religions. Whatever the reason for Madrid's selection, some in Spain are already trumpeting the choice as a kind of consecration of Gonzalez's leadership and of Spain's reemergence onto the international scene since the dictatorship of Gen. Francisco Franco. With the country hosting the summer Olympics in Barcelona and a universal exposition in Seville next year, Spain was already preparing to be in the world's focus. With the peace talks, that will begin a bit sooner.