because atomic weight of carbon is 12 and also, no. of proton and neutron were also 6 each which sums up to 12. So it was concluded that carbon will be the best atom for comparison of atomic masses of other elements' atom as it had exactly 12 atomic mass.
Earlier it was thought that hydrogen should be compared with other elements as it had atomic mass 1, but it had three isotopes which made its average atomic mass not equal to exactly 1. Oxygen was taken before hydrogen for comparison as it reacted with a large no. of elements.