Well that's sort of what happens in a democracy - people are free to vote and associate. It's not like China doesn't take advantage of that itself in other countries, such as when Chinese ambassadors have the opportunity to write opinion pieces in leading newspapers. That's also not a right afforded to US, UK or other European ambassadors unless they're praising China. Or setting up the Confucius Institutes to promote a positive image of Chinese policies and ideas. Or even helping organise overseas Chinese students to attend pro-China rallies/counter-demonstrate against anti-CCP protests.
If the CCP doesn't like what groups in Hong Kong were/are doing, it should have forgone all the conveniences and freedoms of the democratic world and just operated using the same policies as it has at home.
Sure, but the point remains - a directly-elected Chief Executive would have been highly unlikely to pick fights with Beijing or sought to antagonise it for no reason, because it would have pleased only a small number of people and worried a much larger group.
I don't want to sound like a broken record player, but the CCP's refusal to impliment full democracy in Hong Kong is probably the key reason for an increase in the number of groups operating in the city opposed to the CCP. For the first 10 years after the handover, bar a few small groups the most HK did to "oppose" the CCP was to commemorate the 1989 Beijing massacres. If the CCP had kept its promises (and done so say by 2010 - in time for the 2012 elections), there simply wouldn't be nearly as much hostility towards it as there is now. Any political analyst worth their salt could have told the CCP that they were on a road to create the circumstances they said they wanted to avoid at all costs.
I think the CCP has a very thin skin and is too used to getting its own way. Governments across the world have to deal with this sort of thing on a daily basis. Plenty are able to do so without silencing people via the law - e.g. ignoring the smaller groups, putting out their own information to counter negative coverage, negotiation & consultation where the people in question may have a point, supporting groups that foster a positive message, lawsuits in the most outrageous claims, etc.
For example, if the CCP was embarrassed by books that exposed how many of the top leadership used their positions to enrich themselves, the answer wasn't to intimidiate the people that wrote or published them but to take real action against corruption (rather than use purges as a tool against political opponents). Public employees are still woefully paid in so many situations that it actively encourages them to be corrupt in one way or another, whether it's to do private work off the books, accept bribes or use connections for themselves and their families. A proper anti-corruption drive coupled with wage increases would help China.