The best way to install tree on a Mac is to use a package manager such as Homebrew. Once Homebrew is installed, you can install tree using the following command:
brew install tree
If you don't want to use Homebrew, you can download the tree binary from the project website and install it manually.