The military also misjudged the militant group’s capabilities.