How to figure out number of atoms in a molecule? e.g. Phosphorus exists as P4
You are asking how to identify the standard state chemical structure of an element; this is obtained from empirical data.

The standard state is defined as the most stable allotrope of the element under standard conditions. For example, graphite is the standard state for carbon. Phosphorus, however, is an exception: while white phosphorus is not the most stable allotrope, it is the easiest to characterize, and is defined as the standard state for phosphorus.

The chemical formula for each element at standard conditions is that of the standard state. Except for the gases $\ce{H2, N2, O2, F2, Cl2, Br2, I2}$, and the solids $\ce{P4, S8}$, all other elements exist in monatomic form in the standard state.