With growing concerns over environmental pollution associated with fossil fuels, hydrogen (H2) energy has emerged as a promising alternative. Water electrolysis, a key hydrogen production method, is fundamentally governed by the nucleation and stability of electrochemically generated nanobubbles. This study employs coarse-grained molecular dynamics (MD) simulations incorporating a self-programming gas generation algorithm to investigate the nucleation and growth dynamics of nanobubbles on hydrophilic and hydrophobic electrodes. Key parameters, such as contact angle, electric current, and nanobubble number density, were computed to validate the MD model. The findings reveal a three-stage nucleation process: (i) induction-gas molecules accumulate to form a nucleus, (ii) nucleation and growth-gas nuclei expand into nanobubbles, and (iii) stationary state-nanobubble growth ceases. Increased electrode hydrophilicity resulted in larger nanobubble contact angles, aligning well with classical nucleation theory (CNT) at the nanoscale. Three distinct nanobubble types-surface, solution, and pancake nanobubbles-were identified, each exhibiting unique interfacial behaviors based on electrode properties. Solution nanobubbles primarily formed on hydrophilic electrodes, pancake nanobubbles adhered to hydrophobic electrodes, and surface nanobubbles appeared as spherical caps. Energy analysis and phase mapping further delineated the critical parameter ranges for these nanobubble modes, providing valuable insights for optimizing electrode materials to enhance hydrogen production efficiency.