Transition metal phosphides (TMPs) and sulfides (TMSs) are widely-reported electrocatalysts for hydrogen evolution reaction (HER) in alkaline media. However, the origin of their high HER catalytic activity remains unclear. Herein, the transition of NixFe1-xP and NixFe1-xS in catalyzing HER reaction is systematically investigated by X-ray photoelectron spectroscopy and in-situ Raman technique. It was found that, during HER reaction, dissolution of S and P occurs and is accompanied with dynamic evolution of the catalyst surface. The dissolution of P in NixFe1-xP leads to in-situ generation of α-FeOOH species, whereas NixFe1-xS is found partially transformed into γ-FeOOH phase. Density functional calculations reveal that the α-FeOOH (1 1 1) surface exhibits more delocalized electrons offering promoted HER reaction kinetics over γ-FeOOH (0 1 0), and thus contributes the improved activity of NixFe1-xP pre-catalyst. This study unveils the distinct origin of HER activity of TMPs and TMSs, providing potential guidance for the rational design of active HER electrocatalysts.