The United States urged Americans to leave major parts of the Middle East immediately, warning of “serious safety risks” as tensions escalate across the region.