I work for a small company. We don't have a dedicated HR function, but what we do have is a recruiter who we do a lot of business with. As such, he is in possession of our coding test, gives that to candidates, gets the results back from candidates and sends it on to us. I've had a similar experience with technical tests and coding tests when applying to other companies, even some moderately sized ones.
However, if we found out that our friendly recruiter were giving out answers to the coding test to other candidates, letting them know about what questions we might ask or anything like that, he'd very rapidly stop being our friendly recruiter. As you've already realised, that's completely unethical - as a company, we expect every candidate to be on a level playing field, not that some of them have been given the answers.
It's probably also worth reading What is the proper way to deal with an unethical recruiter?What is the proper way to deal with an unethical recruiter?, and in particular Jacob G's answer - if you find yourself dealing with a recruiter acting like this, just go straight to the hiring company and let them know.