In June, hundreds of thousands of young protesters connected by messaging apps took to the streets of Hong Kong to protest the encroachment of China’s central authorities on life in their city.

Four months on, antigovernment demonstrations have swept more than a dozen countries. From Chile and Bolivia to Lebanon and Spain, millions have taken to the streets—sometimes peacefully, often not.

Thousands...