Basic Understanding of Relative Atomic Mass
It's because there's two hydrogen atoms in water, not one. In order to show you, let's assume we're making HO instead of H2O. This would clearly only require half the amount of hydrogen, but still the same amount of oxygen. Thus we have .5 grams of hydrogen combining with 8 grams of oxygen in a 1:1 relationship. Thus the oxygen weighs 16 times more than the hydrogen. Do you understand?

In H2O they combine in a 2:1 relationship. We have 1 gram of hydrogen combining with 8 grams of oxygen, but because there's 2 hydrogen for every oxygen, we actually need TWICE as many oxygen atoms to have the same amount of atoms. In other words, there will be the same number of atoms in 1g of hydrogen as there is in 16g of oxygen.