Oxygen reduction reaction (ORR) and oxygen evolution reaction (OER) are crucial processes at the cathode of zinc-air batteries. Developing highly efficient and durable electrocatalysts at the air cathode is significant for the practical application of rechargeable zinc-air batteries. Herein, N-doped layered MX containing Co2P/Ni2P nanoparticles is synthesized by growing CoNi-ZIF on the surface and interlayers of the two-dimensional material MXene (Ti2C3) followed by phosphating calcination. The growth of CoNi-ZIF on the surface of MXene results in the attenuation of high-temperature structural damage of MXene, which in turn leads to the formation of Co2P/Ni2P@MX with a hierarchical configuration, higher electron conductivity, and abundant active sites. The optimized Co2P/Ni2P@MX achieves a half-wave potential of 0.85 V for the ORR and an overpotential of 345 mV for the OER. In addition, DFT calculations were adopted to investigate the mechanism at the atomic and molecular levels. The liquid zinc-air battery with Co2P/Ni2P@MX as the cathode exhibits a specific capacity of 783.7 mAh g-1 and exceeds 280 h (840 cycles) cycle stability, superior to zinc-air batteries constructed by the cathode of commercial Pt/C+RuO2 and other previous works. Furthermore, a solid-state battery synthesized with Co2P/Ni2P@MX as the cathode exhibits stable cycle performance (154 h/462 cycles).