The PTO is supposed to (and its employees are trained to) disallow trademark claims that do not meet the criteria for obtaining a trademark (for example, due to the term being generic, or because of descriptiveness). So a company that sells candy would not be allowed by the PTO to register a trademark for the word "candy".
Now, the situation gets a bit trickier for words and industries that don't really relate, like "candy" and video games (or, as the example in other comments, "apple" and electronics). In this case, the reality is that trademark agents will file a claim for something relatively broad, and the PTO will initially reject the claim for overbreadth (this is the default in practice), whereupon the trademark agent will narrow the claimed goods and services until the PTO accepts it.
In some cases, they do not ever accept such claims - but given enough time, one supposes that you can find a narrow enough set of goods that you can market exclusively with the word "candy".
Of course, the PTO is subject to review by courts. The problem for the PTO is that if they reject something, that decision can be appealed. Parties with deep pockets will always try to appeal if they think the mark is worth enough (see Apple). So it's a waste of the PTO's time and effort to be very aggressive in denying claims.
In effect, the process is just one of narrowing and back-and-forth negotiating, rather than a "yes"/"no" decision.
In short, the PTO gets blamed a lot for accepting shitty claims (both patents and trademarks), but they really don't have that much incentive to reject claims aggressively, because they get money from applications, and rejections are subject to review anyway.