The trick is it can't be work, only work like things of no value. You can have unpaid internships so long as you are getting training and not doing valuable work.
A railroad engineer intern can move cars around the yard all day, assembly trains, and other such things. However if they move the car to a loading dock where it is loaded/unloaded that is valuable work and must be paid. If the train they assembly leaves the yard for the next that is valuable work (unless they all make it back to this yard unused).
Most companies choose to pay interns rather than figure out how to not break the rules. A few have a separate intern program where they carefully figure out tasks to assign interns for training. If your intern program did valuable work you should talk to a lawyer.