Oh, I had yet forgotten to answer why Spain was attacked?
NOBODY can say, of course. Me, I can only speculate.
First thing, you need to know about the background between Morocco and Spain. The two lands don't have much sympathy for each other, but they need to work together:
* Spain fishes at Morocco's seas. That's the economical reason why Spain as a country is interested in Morocco.
* Spain has two cities in Morocco's natural territory, that's the political reason why Spain is interested in Morocco.
* Morocco is much less developed and produces much less richess than Spain, therefore spanish companies can outsource in Morocco and thus lower their costs, while Morocco notices a small but steady flow of money.
* Spain is the natural bridge between Morocco and Europe. That's the political reason why Morocco is interested in Spain.
* Both lands are really neighbours, and like it their governments or not, when you get to know your neighbour, differences erode and you are more receptive to see him in a positive light. Therefore, regardless of governments, democratic neighbours are usually (notice the usually, please) destined to understand one another and to benefit from each other.
* Both lands have their own terrorist and separatist groups. Each of them as fanatic as the other, none too eager to put bombs on their own land unless attacking determined "political" objectives, but not so reluctant if the civillian lives lost are outside "their land".
I am afraid that all proves I can produce about those facts would be either in Spanish or French (I can't read arabic), probably there are newspapers that have translated articles or so, but that would be much harder to find. Now, what I've said here are known facts, ok? From now on starts my speculation, more or less reasoned and more or less wrong. This is made from taking known facts and giving an explanation that suits them and my "feeling" of the situation.
For the past years, it has suited fine to the spanish government that there were terrorist groups in Morocco. Not that they have been actively promoted, but they have been tolerated and not actively prosecuted. A sample of that is the bombing in Rabat which has found burocratical obstructions in all leads that passed through Spain.
Of course, that doesn't generate simpathy, but has given the government a lever with which to press for fishing rights, which are diminished every year by the Moroccaner government.
On the other hand, Spain has a large base of inmigrated moors, either legal or illegal. Most of them come looking for work or just pass through to upper countries in europe.
Some of these people are respected members of the community, but integration takes time, cause there are lots of prejudices on both sides, and the speed of inmigration flows, "overflows" the speed of integration. Besides, it's not the best economical moment you've ever seen, and unqualified jobseekers have a great deal of insecurity. Most of the newcomers arrive illegally trying to find a job to survive them and their families (which they try to bring to Spain as soon as they can). However being illegally in Spain, asides from the inherent lack of security, allows them little or no rights.
Where leads all this? To lots of people who come searching for a better life, some good and some bad (like everywhere I guess) but all foreigners. If even the locals turn sour due to the difficulty to plan a future in the land, how would that be different with foreigners? Some have nothing to loose, so they simply turn to easy money: delinquence. Therefore the amount of delinquent foreigners grow, and the perception of the locals is that all foreigners are delinquents.
This generates lots of mistrust, and ressentment. Lack of integration and ghetto-like residential habits for foreigners. Some of them are forced to go back to their land, where they seed resentment (as you'll understand, those who go back aren't the happy ones!).
Also note that most of the islamic terrorism comes from relatively well-established citizens. Universities are favourite recruitment sites both because people are young and easily influenced and because there they have access to details about how the rest of the world is and how their land is seen or evolves or whatever (I'm not that sure of how that is exactly, cause this is hard for me to imagine, so don't come hard on me on this point, I should simply state that most planning and seeding terrorists are literate people... relatively literate people).
So, we have resentment and we have now a model that inspires them, the so-called "AlQaeda organization" has jumped to the news due to their 11-S "success" (that is, they succeeded in jumping to the news and generating more hatred). They simply follow that model, and find justifications where they can.
You must understand that hathred feeds on injustice, but goes much further away. Therefore fighting it with injustice (or more hatred FWIW) leads to essentially much more hatred than you had before. High motivated people who want to do something "for their people" will always be easily redirected towards hating outsiders. That happens even in democracies, and to you and me and to everyone. Only not at these levels because we have a different background and objectives.
So, if instead of feeling abused as countries, they could redirect their own efforts to make their lands better, they'd do it. However they see no solution and therefore resort to violence. And that's what's happened in Madrid.
This murders are much more related to what happened in Casablanca on May the 16th. Most likely they are the same group. I wish more was known about what happened there and why, but it didn't make the news, and Morocco is NOT an ally of the USA or something like that.
Besides, it is hardly an objective of terrorists to change other people's mind unless they can be totally aligned with their own, which is usually a flawed reasoning that never works. In this case, it is highly doubtable that a group radicated in Morocco would want to stop the war in Iraq by attacking one of the allies of the USA. It's much more likely that they *could* easily attack in Spain and therefore searched for an argument to do so. But note that had it been France the country nearby, that would have been the objective, and the reasons, the opposition of the government to the religious "rights" of the muslims.
So, no, the objective of terrorists wasn't stopping the Iraqi war. The reason why Madrid was bombed is obvious: press coverage and ease. They can easily move around, and fly back. These aren't suicidal attacks, I remind you, this people do not want to die, but to do damage.
So, no, sorry, the Iraqi war has only given them a reason to justify their attack. The global behavior of the whole Western world is what leads to the hatred of the ground people who are manipulated by extremists. Not that much different from what happens in the USA, or in Spain or everywhere else. Democracy per se is no solution unless the right tools for development are implemented.
Who wants freedom when they don't have bread, and their neighbours throw away the food, not allowing them to even gather the rests? You just want to hurt them.
We all carry a part of burden in this situation. Of course not something that justifies this barbaric situation, but we are nevertheless somewhat guilty. Life is never white or black or so easy as most politicians would want us to think, therefore I refuse to think in those terms and that's my way of fighting for a better world, which I consider legitimate, mind you.
And last but not least, I would like to make something very very clear:
I am always in for a polite debate and I regret if I sometimes become too personal, but I assure you it's nothing negative in this case, since I have come to appreciate the persons behind the opinions exposed, even as though they are not mine... or better said: because they are not mine. Broadening my horizons always makes me feel like I've accomplished something. So thank you for taking the time to read this, and for your eventual reply. Disregard any offensive "jaws" as rethorical figures if necessary :-)