Can an agency apply for a patent?

You can't.

First, there are relevant provisions in the law, such as the Patent Agency Regulations.

Second, in principle, it is not allowed. If an institution can apply for a patent, who will protect the rights of the applicant?

In addition, a patent agent may not apply for a patent during the practice of the agency and within 1 year after leaving the agency.

Article 20 of the Patent Agency Regulations: A patent agent shall not apply for a patent during the period of engaging in patent agency business and within one year after leaving the patent agency business.