In zsh, as in bash, "#" is used as a comment line. However, when typing directly in an interactive shell, lines beginning with # may be interpreted as commands unless setopt interactive_comments is enabled.
If you want the interactive shell to recognize a comment line as a comment when you type it, add setopt interactive_comments to your .zshrc and it will work just like bash.
This page is auto-translated from /nishio/zshで#をコメントにする using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.