The construction of a Pt-based single-atom alloy (SAA) catalyst could concurrently fulfill the demands for low Pt loading and high performance of the cathode of a proton exchange membrane water electrolyzer (PEMWE), but its controllable synthesis remains a challenge. Herein, we report the successful fabrication of carbon shell-encapsulated Pt-doped NiFe single-atom alloy (C@Pt-NiFe SAA) catalysts via a spatial confinement strategy, followed by an investigation of the detailed formation process. As expected, compared with commercial Pt/C, C@Pt-NiFe SAA exhibits enhanced mass activity for the acidic hydrogen evolution reaction (HER). Remarkably, when integrated into PEMWE cathodes, C@Pt-NiFe SAA also outperforms commercial Pt/C. Operando X-ray absorption spectroscopy (XAS) characterization confirms that the low-coordination Pt sites generated in situ during the reaction serve as the main active sites, whereas theoretical calculations confirm the optimized electronic structure and ΔGH* of the Pt single atoms, which jointly contribute to the enhanced HER activity of C@Pt-NiFe SAA. Inspiringly, this spatial confinement strategy can be universally used to prepare other platinum group metal (PGM, PGM = Ru, Rh, Pd, Os, and Ir)-based SAAs. This work not only shows that C@Pt-NiFe SAA is a promising candidate catalyst for use at the cathode of practical PEMWEs but also stimulates research interest in further exploring the promising applications of other PGM-based SAAs in the broad electrocatalytic field.