Two municipal water systems in New Jersey were targeted in cyberattacks widely thought to be the work of Iran, the state said Wednesday.