TLDR: It's going to be hard to figure out motivation. Probably a mix of deteriorating relations and desire not to "lose face" from US political pressure.
From Phillipp's Chinese Foreign Affairs link:
A: US law enforcement personnel ensnared Chinese nationals through “sting operation” in a third country and blatantly pressed charges against Chinese entities and individuals. This is typical arbitrary detention and unilateral sanction, which is completely illegal. It seriously harms the basic human rights of the Chinese nationals and the interests of the Chinese companies concerned. China strongly condemns this move and has lodged serious démarches and strong protest to the US side.
But it also looks to be current Chinese foreign policy to disclaim any link to fentanyl. (Note that Mexico's Obrador is hardly very pro-US)
The Mexican president says his country has proof that illegal shipments of the powerful opioid drug fentanyl are arriving from China.
A container with hidden packages of the drug was intercepted in the Pacific port of Lázaro Cárdenas, President Andrés Manuel López Obrador said.
"We already have proof," he said, adding that he would ask the Chinese government to help stop the shipments.
To which China replied:
Last month Chinese foreign ministry spokesperson Mao Ning said "there is no such thing as illegal trafficking of fentanyl between China and Mexico".
My opinion on the matter is that China's position is probably linked to both deteriorating US-China relations and the fact that the US has too publicly called it out about the matter. In the past there had been some lower key collaboration and large scale fentanyl trafficking is punishable by death in China.
U.S. slams China's 'unacceptable' disruption in countering fentanyl | Reuters
WASHINGTON, Aug 8 (Reuters) - China's move to suspend cooperation with the United States to combat narcotics trafficking, including illicit fentanyl, is "unacceptable," the White House said on Monday, as Beijing continued to protest a visit to Taiwan by U.S. House Speaker Nancy Pelosi.
And it is becoming a political football, with (Rep) POTUS hopeful Halley joining the fray:
"I will push Congress to revoke permanent normal trade relations until the flow of fentanyl ends. If China wants normal trade, it has to stop killing Americans," Haley, the U.S. ambassador to the U.N. under former President Donald Trump, wrote in an op-ed in the Wall Street Journal.
Canada, in March 2018, months before the Huawei arrest case soured relations also had come to the conclusion Chinese individuals contributed to the precursor chemical trade:
China has been identified as the main source country of fentanyl found in Canada.
Background investigations by NPR