It is not illegal to join Anonymous because you cannot join. Officially, there is nothing to join, although the collective does provide instructions on joining.
Confused? That's because you're supposed to be. Anonymous is a collective of computer coders, hackers, protesters, and geeks who are loosely linked on the web and are, well, anonymous. They do not use their real names. But Anonymous does instruct on affiliation, and following these instructions is not illegal per se.