Let's clarify.
It is legal to work as many jobs as you like. There is no law that says you can't work for eighteen different employers if you want to and can fit all the jobs into your day. While being an employee (W2 at the end of the year) is the default, if some of the jobs legitimately qualify to be IC (1099 at the end of the year) that's perfectly fine.
However, working a second (or third, or eighteenth) job is not a protected activity. Therefore, if one (or more) employers objects to your working a second job, either because it's affecting your flexibility, or because of a conflict of interest, or because you're so tired you're making mistakes, or just because, and that (or those) employers decide to fire you because of it, that is legal too.

