$PATH is a list of paths separated by colons. When you type a command into the
shell, it looks at all these locations for an executable matching the name you
typed and will execute the first one it finds.

This is why some tool installation guides ask you to modify $PATH in your
shell config.

You can see which path your shell is using for a given command with which

$ which ls
/bin/ls

Sometimes you will have multiple versions of a command installed. For example
psql from Homebrew and psql from Postgres.app. The which command is is
great for finding out which one is being used. Use this info to tweak your
$PATH to ensure the right one loads. You can also use the -a flag on
which to show all installed executables: