Why is the molecular formula of a gas not necessarily the same as its empirical formula?

At higher temperatures, those that produce a gas, say, from a liquid, the kinetic energy of the molecule is large enough to break those bonds holding more than one molecule together. Thus, H2O, in the liquid state and at low temperatures, occurs in units of six, at higher temperatures the units are groups of 4 and at the boiling point of water, in the vapor state, it is H2O in unimolecular form.

The molecular formula of a compound represents the actual number of atoms of each element in a molecule, whereas the empirical formula represents the simplest whole number ratio of the elements in a compound. In the case of gases, the molecular formula is not necessarily the same as the empirical formula because the behavior of gases can cause the molecules to break apart or combine differently than they do in solid or liquid states.

In the example you provided with water (H2O), at low temperatures and in the liquid state, the water molecules are typically associated in clusters or groups. These clusters consist of multiple water molecules held together by hydrogen bonds. So even though the empirical formula of water is H2O (meaning there are two hydrogen atoms for every one oxygen atom on average), in the liquid state, there may be clusters containing more than one H2O unit. Therefore, the molecular formula of water in the liquid state may be expressed as multiples of the empirical formula H2O, such as H12O6.

As the temperature increases and the water molecules gain more kinetic energy, the hydrogen bonds between the molecules become weaker. Eventually, at higher temperatures or at the boiling point of water, the kinetic energy of the molecules becomes large enough to break the hydrogen bonds, resulting in the separation of individual H2O units. In the vapor state (as a gas), the molecular formula of water reverts back to H2O in the unimolecular form, where each water molecule is independent and not associated with other water molecules.

So, the change in temperature and state of a substance can affect the arrangement, interaction, and bonding between the molecules, leading to differences in the molecular formula and empirical formula of gases compared to their solid or liquid counterparts.