A new history of the post 9/11 war on terror shows how badly America and its enemies misunderstood the consequences of their own actions.