Pentagon documents show that the US air wars in the Middle East have been marked by "deeply flawed intelligence" and resulted in thousands of civilian deaths, including children.