score:9
This question is too broad, but I'll give you some avenues of research.
Note all the countries you use as examples mention were puppet states and colonies right up until, and a bit after, WW2. Iraq and Libya were carved from former Ottoman states, and the Ottoman Empire was not known for its efficiency. These territories were seized by the Allies after WW1 and saddled with colonial or puppet governments or unstable dictatorships. Nigeria was a British colony. And Somalia was a British and Italian colony. Being about exporting raw materials, they have little existing economic, governmental, nor industrial base to build upon. Many are formed from arbitrary lines on a map and have little national identity. While relatively unravaged by war compared to Europe, their governments were western puppets until independence in the 50s and 60s leaving little chance to develop stable governments.
Iran had continuity as Persia, and its history is more complicated. In the 18th century they were one of the most powerful nations. But the early 19th century saw its northern territories gobbled up by Russia. The late 19th and early 20th century saw famine, protest, the forming of a constitutional government, Russian occupation followed, Ottoman invasion and genocides, famine, and British occupation. They came out of WW2 mostly intact with a democratic government. Unfortunately his nationalization of the oil industry made the US and UK nervous, so he was overthrown in 1953 and replaced with a dictator. This proved very unpopular in Iran and lead to the 1979 Iranian Revolution and Iran as we know it today.
In contrast, Japan and Germany were well-established industrialized nations with functioning governments and national identities. Though devastated by war, they retained the foundations of their economies and government: skilled workers, teachers, traditions, relationships, resources, geography etc... After a brief occupation they retained their identity and (for West Germany, East Germany would come later) continuity of government. Western Europe received massive post-war aid from the Western Allies in the form of the Marshall Plan. Japan's reformed government engineered an economic miracle, bolstered by its use as a base of supply for the Korean War. In all cases the Western Allies had an interest in keeping the people of Western Europe and Japan happy and not communist.
As an interesting contrast, consider Turkey. While not spectacularly well off, they are relatively stable. Like the others they were also a former Ottoman state. Unlike the others they had a strong identity as Turks and resisted being carved up by the Allies after WW1, forged their own government, and have largely been left to their own devices.
The question is very broad, my answer is very broad. You can see the through line of negative foreign influence and meddling in a nation's history. I encourage you to look further into the history of each region, and what sort of foreign influences and interference they've had over the centuries.
Upvote:2
Start by reading this article about the Marshall Plan
Starting with a few quotes (emphasis mine):
The goals of the United States were to rebuild war-torn regions, remove trade barriers, modernize industry, improve European prosperity, and prevent the spread of Communism.
And
The purpose of the Marshall Plan was to aid in the economic recovery of nations after WWII and to reduce the influence of Communist parties within them.
And
Congress, under the control of conservative Republicans, agreed to the program for multiple reasons. ... Senator Robert A. Taft (R-Ohio) hedged on the issue. He said it was without economic justification; however, it was "absolutely necessary" in "the world battle against communism."
So what was the Marshall Plan? Basically, 3 years after the end of WWII the economy of France and Britain was still quite weak. The US feared[1] Soviet Union was planning to spread its influence through Europe and later the world. So it decided to inject money to stop the spread of communism.
After WWII US policy experts had the Morgenthau Plan which would leave Germany destroyed. The Morgenthau Plan had decreed that it would
take no steps looking toward the economic rehabilitation of Germany [or] designed to maintain or strengthen the German economy.
It appears that US policy makers had a change of heart when they realized that an impoverished Germany was (1) fertile ground for the spread of Soviet influence, and (2) that France and Britain would find economic recovery slow without Germany. Quoting a quote again from Wikipedia:
Thereafter, JCS 1067 was supplanted by JCS 1779, stating that "an orderly and prosperous Europe requires the economic contributions of a stable and productive Germany."
So US military technocrats realized they needed strong allies in not just France, Italy, and Britain, but also Germany. The US secretary of state, George Marshall, was a retired general who was instrumental in organizing the US war economy. He bought into the idea, and created the plan that bears his name, "Marshall Plan". With the ascent of communism via the CCP and Mao in China, it was decided that the US also had a strategic interest in a strong Japanese economy.
Thus, without the threat of communism, the Americans likely would have done nothing to help the Germany or Japan, nor honestly, anybody else.
So, now onto your question, which is "but countries war-torn in most wars, later, continue suffering?"
Directly answering your question:
Let's consider Iraq. So The US invaded Iraq in 2003. The right thing, after conquering this territory, would have been to build a strong democracy with a modern economy. This would have required a huge investment and 20-30 years of work. However, without the threat of communism or a cold war, Americans didn't really have enough motivation, or concentration to do that.
When I look at this list of occupied countries, I see most wars and occupations by the US as being fairly short. For example, Panama. Only Iraq and Afghanistan had a lengthy post war US occupation and nation building measures.
Other nations that have been conquered were not conquered by a wealthy counrey capable of rebuilding. For example, when India annexed Goa, India was per-capita poorer than Goa, so it wouldn't make any sense for India to make Goa as wealthy as Japan.
Controversial addendum: The US motivation to invade Iraq is fundamentally unclear to most people. It was purely about economic growth, as was was viewed by the Bush administration as a key to GDP growth.
[1] This statement does not address if the Soviet Union was actually expanding. All that matters, in the context of that Marshall Plan, was that the establishment in the US feared the spread of communism. However, Greece did have a communist insurgency.
Edit:
@jamesqf has provided the following correct critique to this answer. He wrote it elegantly, so I quote it in full:
This is only a partial answer. What you miss is that the WWII losers were already prosperous, industrialized countries prior to their defeat, so they only needed to be RE-built. The people already understood how to run an industrial economy. Iraq, Libya &c were not developed prior to their invasions and/or civil wars, so why should that magically cause them to become developed? They just followed a similar course to most undeveloped countries that weren't invaded
I think what I left unstated is that generally, nations that are conquered do not recover as well as Japan and Germany did. They were aided in their recovery after WWII did due to the cold war. That makes them more of an exceptional case then a general rule.