On Intel Macs Homebrew's prefix is /usr/local, which is already in the default PATH. On Apple Silicon it is /opt/homebrew, which is not, so a fresh install leaves 'brew: command not found' until the shell environment is set up. The installer prints the two commands to run; they append an eval of 'brew shellenv' to the shell profile.
Use 'eval "$(/opt/homebrew/bin/brew shellenv)"' rather than hand-editing PATH, because shellenv also sets HOMEBREW_PREFIX, HOMEBREW_CELLAR, MANPATH and INFOPATH, and it is the documented interface if the prefix ever changes.
Never hardcode /usr/local or /opt/homebrew in scripts or in build configuration. Ask with 'brew --prefix', and for a specific package 'brew --prefix openssl@3', which is the reliable way to find headers and libraries. Both prefixes can coexist: an Intel Homebrew under /usr/local runs under Rosetta via 'arch -x86_64 /usr/local/bin/brew' and is occasionally still needed for formulae without arm64 bottles. Mixing the two on one PATH is a frequent source of 'wrong architecture' link errors.