Of course there was the conquistadors in the 15th, 16th, and 17th centuries, but recently, they’ve been off the radar since like 1900.
How have they avoided these more recent global conflicts?
This is a difficult question to answer cohesively. For one, it's not entirely fair to say that Spain has avoided all wars in the past 200 years - they obviously did not avoid the Napoleonic Wars, which were followed soon after by the Latin American Wars of Independence and other, later colonial conflicts in the dwindling empire. Other international conflicts might include the Spanish-American War. That's without getting into civil conflicts, such as the Carlist Wars of the nineteenth century or the more recent Spanish Civil War. In fact, there's a decent case to be made that the Spanish Civil War was in itself a major European conflict, seeing not just a long, intense war between Spaniards but significant international involvement, including the commitment of troops from Italy, Germany and to a lesser extent the Soviet Union. So, Spain has been involved in plenty of wars of varying scale and intensity in the past 200 years. It has not been a uniquely peaceful place, in other words.
What I suspect your question really boils down to is why Spain stayed neutral during the First and Second World Wars - the only two major Europe-wide conflicts in the period in question. There were certainly other significant European wars in the past two centuries, but there's not any real reason to expect that Spain would have participated in, say, the Crimean or Franco-Prussian Wars. After the Second World War, there have not really been any major European wars to speak of, although Spain was hardly neutral during the Cold War, even before they joined NATO.
So, the world wars. I am no expert on Spain during the First World War, so will somewhat hesitantly point you to this answer from a few years ago. While I'm not sure it's the most substantive answer ever written for this subreddit, it seems unobjectionable to claim that there wasn't any particular reason for Spain to get itself involved in the First World War, although the same argument might be made for other participants (why Portugal joined the war and not Spain, for instance, is an interesting question). In any case, Spain didn't have any colonial or territorial claims on any of the Central Powers. Although I suppose Gibraltar was an outstanding issue, as it is now, Spain was firmly within the British sphere of economic influence (I've heard the argument made that Spain amounted to an informal colony in the early 20th century), and was dependent on Britain for its energy supply in particular, so there was no question that they would or could join the Central Powers.
On the question of why Spain remained neutral in the Second World War, there are several very good responses in the FAQ, as well as my own answer (alongside discussion of Portugal). It's important to note that Spain remaining neutral was a matter of contingency. While the matter is not entirely settled, to my mind there is little doubt that had Hitler been willing to pay the requisite price, Franco would have been willing to join the war in 1940-41. Spain was, in essence, lucky that the cost of meeting Franco's demands were more than the perceived worth of Spanish involvement. Even then, Spain could hardly be said to be detached from either the wider conflict or the Axis cause - Spanish neutrality was, up until 1943, heavily slanted towards Germany in a number of ways, including turning a blind eye to u-boats refueling in Spanish ports, and sending an entire division to fight on the Eastern Front.