Here's why:
* Pronouns stand in for nouns. In this sentence, "both" is replacing a noun phrase like "both of the teachers" or "both of the subjects."
* "All" is a quantifier, indicating the entirety of the students.
While "students" is a noun, it's not acting as a pronoun in this sentence.