Reproducing submillimetre galaxy number counts with cosmological hydrodynamic simulations