Two probability measures supported on one compact interval are equal if all their moments are equal. Indeed, equality on monomials gives equality on polynomials, the Weierstrass approximation theorem extends it to every continuous function on the interval, and compactly supported continuous functions determine a finite Borel measure.
Let and be the probability laws of and . The hypothesis says
for every compactly supported continuous function . The theorem that compactly supported continuous functions determine a finite Borel measure gives . Hence and have the same law.