Apple Inc. and Google both removed apps associated with Hong Kong’s antigovernment protests from their digital stores in recent days, thrusting the two Silicon Valley giants into a controversy engulfing other U.S. companies.

Apple removed from its App Store a crowdsourced map service that allows Hong Kong protesters to track police activity, one day after the Chinese Communist Party-run People’s Daily newspaper lashed out at the iPhone maker, calling the app “toxic software.”

Apple...