I saw a company produce a machine and applied for a patent, but other companies also produced the same machine. Is this illegal?

We should distinguish different situations to identify this problem.

Paragraph 3 of Article 62 of the Patent Law stipulates that "those who have manufactured the same product, used the same method or made necessary preparations for manufacture and use before the patent application date, and continue to manufacture and use it only within the original scope" shall not be regarded as infringement of the patent right.

According to this regulation, if other companies produce the same machine after the date of your patent application, it is an illegal act to infringe your patent right.

If the same machine has been produced before, it will not be regarded as patent infringement according to the law.