Generally, the courts don't care about who is genetically related to who, but establishing paternity is a special case. The specifics are governed by state law, here is what Washington does. Under the Uniform Parentage Act, when there is a legal dispute as to parentage ("is X a parent of Y?")
and X either volunteers for genetic testing, or is tested under order of the court or a child support agency, then the courts and the law gets involved in genetic testing. Testing cannot be used to challenge the parentage of an individual legally established to be a parent in other ways, or to establish the parentage of a donor. There are prerequisites to the court ordering a test,
for example a party may make a sworn statement that there is a reasonable possibility that X is the child's genetic parent, or swears that it's reasonable that the person is not a genetic parent.
Assuming the court issues an order, then RCW 26.26A.315 governs the procedures for the testing. As for the qualifications of the lab and test, the requirement is that
(1) Genetic testing must be of a type reasonably relied on by experts
in the field of genetic testing and performed in a testing laboratory
accredited by: (a) The AABB, formerly known as the American
association of blood banks, or a successor to its functions; or (b) An
accrediting body designated by the secretary of the United States
department of health and human services.
and the sample requirements are
(2) A specimen used in genetic testing may consist of a sample or a
combination of samples of blood, buccal cells, bone, hair, or other
body tissue or fluid. The specimen used in the testing need not be of
the same kind for each individual undergoing genetic testing.
Then there are procedures regarding resolution of disputes of ethnic parameters for computing the relationship index, including changing labs.
Nothing in the law itself states how the samples are to be processed: that is implicit in the accreditation requirements of AABB, and to be legally admissible, chain of custody protocols must be observed for collecting and processing. Chain of custody is a general requirement for evidence and there isn't anything special about genetic testing, see here for an overview and here for some nuances (e.g. the importance of having technically-competent and accurately-documented collection of samples). If the sample is inadmissible because of broken chain of custody, then the court can order another sample be taken.