As the noose around the Islamic State tightens, it has tried to adapt by plotting, inspiring or taking responsibility for indiscriminate attacks around the world: a nightclub in Orlando, Fla., a promenade in Nice, France, a cafe in Dhaka, Bangladesh, a square in Istanbul.