What's the problem?
Synthesis of mercuric oxide:
2Hg + O2 -> 2HgO
Decomposition of mercuric oxide:
2HgO -> 2Hg + O2
In first case 3 moles give 2 moles, in second - 2 moles give 3.
Why do you suppose number of moles should not change? Mass, number of atoms - that's mass conservation law. But number of moles of reagents?