The number of molecules isn't necessarily equal, but the number of atoms in the reactants must equal the number of atoms in the products.
A typical reaction is the formation of water from hydrogen and oxygen.
We see that there are three molecules of reactants (two of hydrogen and one oxygen) and only two molecules of product (water).
However, the Law of Conservation of Matter says that, in chemical reactions, matter is not destroyed or created.
Thus, the number of atoms (which are matter) must be the same before and after the reaction.
There are six atoms in the reactants and the same six atoms in the product.
Thus, the number of atoms in the reactants equals the number of atoms in the products.