Although Spain experienced a gruesome civil war, neither Spain nor Portugal participated in either the first or the second world wars. Despite their losses of millions of people, widespread destructionist of infrastructure and industry and -in some cases- even hefty reparation payments, other European countries have largely been more populous and prosperous than either Portugal and republican/nationalist Spain throughout most of the 20th century. Why?
You need educated population, industrial and technological base, and resources
First condition is simple to understand - you need engineers and qualified workers for your industry, the more the better. Germany is good example for this - although they lost both world wars, German educational system (with foundations laid down in 18th century) produced some of the best scientific minds in 19th and 20th century, and German engineering was and still is considered among the best in the world. Countries like Russia and China that had large uneducated rural population tackled with this problem by creating vast array of new schools, from elementary to universities. Spain on the other hand was considered by its own admission as backwards in this regard at the beginning of 20th century. Measured were taken to rectify this, but then unfortunate Civil War came and much was ruined. During the Franco rule Catholic Church had large influence on education - is that good or bad depends on your political stance. Nevertheless, in that period Spain didn't progress much better (or worse) compared to other European countries, and continued to lag behind best of them.
As for second condition, it is easier to industrialize if you already had experiences with industry :) Example for this would be Germany after WW2. Germany was almost completely devastated in the war, and divided by victors. Still, Germans did know how to create and operate effective industry. As mentioned before, they had educated workforce, but also know-how what could be done and what could not be. Therefore when they got the funds they quickly become very efficient. Compare that with Chinese Great Leap Forward and many blunders like backyard furnaces. Countries that didn't have experience with industry often made errors easily avoidable by those with knowledge. Unfortunately for Spain, until the beginning of 20th century it was mostly agricultural. Attempts of industrialization before Civil War were sporadic, and during WW2 and immediately after it there was no realistic chance to build lacking infrastructure. Only in latter years of Franco rule (from 1960's), with the help of foreign investment, industrialization in Spain picked up pace and somewhat closed the gap to world's leading economic powers.
Finally, for your industry you need raw resources to process, either domestic or imported. In latter case you would need convertible currency. Large countries like Russia, US, China etc ... usually rely on domestic resources, with some exception like for example Chinese need for oil. Mid-sized countries like Germany depend on foreign resources (this was actually one of the reasons for both WW1 and WW2 ) . After losing majority of colonies in 19th century Spain also became mid-sized country, therefore it did depend on overseas trade to acquire lots of its needs. One example would be cotton, despite domestic production Spain's textile industry depended on imports, and from 19th century these had to be paid with hard currency. Note that during WW2 (and to a much lesser extent in WW1) many critical materials could not be imported at all, because of naval blockade and submarine warfare. After WW2 Spain was largely isolated as it was seen as pro-Axis, this changed only in 50's when Spain accepted US bases on its soil in exchange for capital inflows.
I cannot give you a definitive answer, but I think some of the general ideas are flawed:
Starting point: You should not understimate the differences at the beginning of the 20th century between Spain and Portugal in one side and France, the UK and Germany in the other.
War is only destruction: Yes, there is a lot of destruction in a war. But it also gives the government an opportunity to mobilize all the economy towards its aims (sky high taxes, promotion of strategic industries, forced labor, etc.)
War damages are permanent: Yes, a bombing campaign can be devastating on the infrastructure. Yet after the war is over, if you have a well formed workforce industrialization can happen relatively quickly (and even better, due to more far reaching modernization than otherwise possible)
Wars are long: WWI meant a boom for the Spanish industry, but it only lasted four years. Four years may look like a lot of time, but if you have very little basic industry and infrastructure it is difficult to significantly expand it in that time.
You ignore internal factors: During WWI, the high price paid for goods by the countries at war meant that prices did raise in Spain, too, leading to the Crisis of 1917. During WWII, Spain was devoid of any industry worth mentioning due to the Spanish Civil War.
Wars do not affect neutral countries: With all the capital and resources of the major countries being used up at war, there were little resources to spare to build new industries in Spain. And of course, embargos and submarine warfare can affect neutral countries, too. And usually neutral countries end up spending more in their own militaries to try to protect against a possible involvement in the war.
Industrialization spreads: Well, it somehow does. But there is a bonus for building factories at places that already have all the infrastructure, suppliers, customers and workforce needed; there is an incentive to concentrate the industry. In the end, millions of Spanish workers emigrated to the industrial centers of Europe because it was easier (or cheaper) than building new industrial centers in Spain or Portugal.
Also, you are forgetting both the Marshall Plan, the Spanish Civil War (which was quite crippling) and the Spanish War in Morocco. Portugal was somewhat more peaceful, but it also fought some colonial wars (Goa, Angola, Mozambique).
Because they were dictatorships
Both of those countries were repressive dictatorships until quite recently. 1976 in Portugal's case, and Spain redemocratized during 1975-78. That's recent enough that I remember watching Saturday Night Live Weekend Update skits about both as they were happening.
It's not impossible for that kind of government to produce robust and stable economic expansion, but it would be highly unusual. Far more typical (and really, human) is for the people in power to mostly line their own pockets, at the expense of the nation.
According to economists Papaioannou and Luiten van Zanden, there's a measurable economic retarding effect with long-running dictatorships, reducing growth, increasing inflation, and weakening institutions, which they termed The Dictator Effect. The dictators in Spain and Portugal both ruled for 36 years (although Portugal's regime lasted another 7).