The attacks showed how both Iran and the United States were seeking to exert control over shipping in the area. Even as Mr.