Simply double-clicking on a foo.tar.gz compressed item in the Finder will unpack it. I recommend creating a new folder, and placing the *.tar.gz file in it first. That way, if the creator did not include its original folder and just files, you can contain them in the new folder and not spray all over the Downloads folder.
Apple has been using the Bash shell for decades and has switched to the Zsh shell since it has an MIT license. Apple has included a notification in the Terminal about changing to the Zsh shell and associated syntax to do that, but it is optional and you can continue to use the old Bash shell.
Otherwise in the Terminal, I would do this first to see the structure of the tar contents without extraction. The following works in Bash or Zsh shells.
tar -tf foo.tar.gz | more
If you do not want the enclosing folder, should it be shown from the above, you can remove it and just unzip the subsequent content hierarchy into the current folder with this adjustment:
tar -xf foo.tar.gz --strip-components 1
The tar -f flag detects what type of compression was used and invokes the appropriate uncompress tool before extraction occurs.