Why not to consider hydrogen and oxygen moles to determine an empirical formula
The answer is $\ce{C3H4O4}$. It was found by using the mass (percentages) divided by the molar mass of each element. 


Exactly! That's the way to do it.


  But they didn't consider the (2moles) of hydrogen and oxygen in calculations. Why? In this case it will be $\ce{CH3O3}$


No, they did not! As you have pointed out yourself, it is about the empirical formula of a compound in question, such as one of the following:



It is completely irrelevant whether an element usually exists as a diatomic molecule in nature. If that would matter, how would you then treat sulfur-containing compounds? Note that natural sulfur typically consists of $\ce{S8}$ molecules! How would you treat elements that only appear in the form of compounds in nature but never as pure elements.

In summary, the "natural appearance" of elements in nature does not matter here, it is only about the relative atomic abundance of an element in the compound in question.