Formulae that would conflict with another package, and almost all versioned ones such as node@20, python@3.12, postgresql@16 and openssl@3, are marked keg-only. Homebrew installs them under the Cellar but does not symlink their binaries into the prefix's bin directory, because doing so would shadow the unversioned formula. The install finishes successfully and the command is still not found.
The caveats text printed at the end of the install gives the exact PATH line, and 'brew info node@20' reprints it later. The stable way to build the path in a script is 'export PATH="$(brew --prefix node@20)/bin:$PATH"', which survives a prefix change.
For compilers, keg-only formulae also need LDFLAGS and CPPFLAGS, and often PKG_CONFIG_PATH, all of which appear in the same caveats. 'brew link --force node@20' does create the symlinks, but it then conflicts with any later install of the unversioned formula and is not recommended. 'brew unlink' and 'brew link' are the supported way to switch which version is active.