If a person is running a print shop where there are given STL files by customers, and they print the part for them, does the legality of the printed object matter? The customer would be supplying the file so the print shop would not know if it was legally obtained (or even what the object is). Could the print shop get in trouble with the law for this?
There are two aspects to this question that probably should be addressed separately. This is not legal advice and I'm not a lawyer, so consult with an experienced IP attorney.
Copyright law may apply, and other IP laws, such as patents and trademarks, may apply. They each have different requirements and restrictions.
Notably, IP law varies from country to country. WIPO has made significant inroads into regularizing IP law across many countries, but this answer will still focus on a US-centric reading of US IP law.
It's already established that printed works, such as photographs, texts, and similar works will result in prosecution against the person and the company that the person outsourced the copying of the copyrighted work to. Attempt to copy a book or copyrighted photo at a paper copy shop and they will typically refuse to reduce their liability.
Even if you show that you have rights to the work, through educational use laws, for instance, they may still refuse because they may be putting themselves in danger of a lawsuit by a particularly aggressive copyright holder.
This applies to 3D printing shops in a similar manner. If you don't know the source of the 3D model, and that the person has a right to the model, you may find yourself liable for copyright infringement. Even if you are sure, a lawsuit can financially ruin your business if it comes from a large corporation.
Patents apply even if you were unaware of them. So any model you print that contains patented techniques, technology, or concepts may also pull you, as the print shop, into a lawsuit for patent infringement.
A suitable contract with the person requesting the 3D print, as written by an IP lawyer, may reduce, but not eliminate, your liability. It won't completely absolve you of all responsibility, but may reduce your exposure to such lawsuits, and give you some leverage in court should someone prosecute you.