Is it illegal for a patented product to be bought and sold by a third party after it is put on the market, but it fails to pass through the patentee? How to deal with it generally?

Not illegal.

This is called the exhaustion principle in patent law.

For example, my patented product was sold to trading company B, and B was sold to C, who was the user of the product. After I sold the product in this transaction, my patent right for the product has been exhausted, and the normal sale and use of the product by Party B has nothing to do with me. Note that this means normal. If B says that the patented product is his when selling, and someone else infringes it, then C will buy it from him, which is patent infringement.