How do compensation lawsuits work?

I’ve been seeing a lot of TV ads telling people they should contact a particular law firm if they used a certain product in order to collect compensation for harm caused by the product.

How does this work? I’m assuming that a law firm needed to provide evidence at some point to prove that the product caused the harm. So what happens then? Once one law firm has proven the case, can other law firms file lawsuits based on the evidence that the first law firm presented?

If so, that seems to give the other law firms an unfair advantage. The first law firm put the resources into building the case but the subsequent law firms get a free ride.

Read John Grisham’s The King of Torts and The Litigators for the process of how class action suits are gathered and conducted.