Why `read -N` doesn't work in this script on mac terminal?

/bin/bash is version 3.2.57 (or similar) which doesn't support -N. You can use -n instead (with slightly different functionality so not sure the timeouts used for K2 and K3 still work).

If you need Bash 5 you can install it via Homebrew.