Countries with their own defense industries like China, the U.S., and Russia, frequently insist upon making their own major weapons systems, even if they import some parts.
Russia does not see China as a military threat to it, so it wouldn't be considered a threat to Russian national security to sell parts for military equipment being built by Russia. Indeed, the Russian government may see selling military equipment and parts for military equipment to China and other countries that are not hostile to it as a national security asset, because it makes the military might of the purchaser countries beholden to Russian cooperation in the long run as parts need to be replaced over time, and as the customer country wants to buy more units of its existing military equipment systems. These national security concerns may outweigh a "Russia first" international trade policy for the Russian government, and even when China sells its finished aircraft, Russia is at least getting the consolation prize of part of the profits from that sale, even though it isn't getting the full profit from the sale as it would if another country bought one of its finished aircraft.
At the time that some Russian company entered into a contract with China to sell the engines (keep in mind that it is a company that happens to be located in Russia and also does business with the Russian military as a defense contractor, and not "Russia" itself that sold the engines), the Russian company that makes completed aircraft with the parts supplied by the common engine supplier, either (1) didn't have the power to prevent the engine supplier from also selling to China (and perhaps wasn't able to get Russian government backing to prevent this from happening out of diplomatic concerns for Russia-China relations), or (2) didn't anticipate that the Chinese finished aircraft would develop an export market that would compete with the Russian finished aircraft. In the second case it is worth noting that, until very recently, China was not a viable competitor to Russia in the exported finished military aircraft market.
Both possibilities are plausible.