Then why don't armies just compare spreadsheets instead of actually fighting? It would save a lot of bother.,Arms races are actually won by calculating the costs versus benefits of every activity. That applies to business as well.
Buying Ka-52s means a closer economic and military relationship with Russia, which is now a quasi-ally.
If China wanted to do it by itself, it would take a few years and cost a lot more.
The military defence spending multiplier is generally between 0.6 and 1.2
So if China can buy these helicopters for half the price of doing it themselves, they can use the overall savings to fund something else instead. That works out better overall for both China and Russia. It's just another example of comparative advantage.