They aren't just sanctioned by the west, there's UN sanctions on NK too. China and Russia are more inclined to abide by UN sanctions than western sanctions. (But this has now changed after the Ukraine war, and both countries do appear to have strengthened military ties with NK).
Moreover, due to the sanctions, NK can't acquire Euros or dollars essential for international trading, and only afford to pay with its own currency. This means that unless there is equal trading between NK and other countries, any trade imbalance in favour of NK would mean the other country would get stuck with a lot of NK's currency in their banks with no real idea what to do with it. That is why China and Russia actually do barter-trading with North Korea (i.e. they mostly exchange goods and services, instead of money, when they trade).