Well-funded Republican groups are helping legislators pass restrictive legislation and defending those laws in court.