There are ways around.
Like the AHL won't allow players of certain age to join. So instead they have to either stick with the NHL or go back to juniors.
There are absolutely no ways around child labor laws. Any contract that forces a minor to play exclusively in any league is 100% illegal.
Anything regarding the NHL/AHL is immaterial, professional leagues don't sign minors in North America.