Effectively they got Marshal Plans. As
@Commodore pointed out in some other thread, the biggest recipients of actual foreign aid (even when counting military spending separately) are those countries. The US has spent enough to rebuild them several times over at this point but a lot of the money has been lost to graft and waste. And because the violence has never stopped, every gain comes with a loss. Sometimes the losses are bigger than the gains, as when ISIS rose up in Iraq.
My father went to both countries at the height of the wars and in Iraq his primary mission was rebuilding and running the zoo, not combat. Can't remember what he did in Afghanistan but point being, a lot of American soldiers get sent over to manage and oversee construction projects, not hunt down insurgents. And then there are the armies of civilian contractors sent over for construction as well.