Lawmakers have special rights, known as legislative immunity, which allows them to enact laws. Thus lawmakers are allowed to say what may legally be done by teachers, without being licensed to teach, and they can say what the law is, without being licensed to practice law, moreover they can say what doctors can do without being licensed to practice medicine, what spies can do without having a license to kill, and so on. Indeed, none of the above acts (of passing legislation) would be violations of "unlicensed practice" statutes, even without the concept of legislative immunity. For example, I can tell you about the legal concept of legislative immunity, without that act being "unlicensed practice of law". In general, anyone in the US can freely talk about a topic: what is forbidden is holding oneself out as an X, if one does not have an X license, for legally-restricted profession X. Finally, legislators do not provide any advice at all, instead, they say what the law is. As do appellate justices, in a different manner.