ssh server2 < archive.tar.gz
You aren't passing any command to
ssh, so it executes a shell on the remote side. The contents of
archive.tar.gz are passed to that shell on its standard input, so it tries to parse it as a shell script. Hilarity may ensue, or not, depending on the content of the file.
It isn't clear in your description where you're running these commands. If you're on server1, have
archive.tar.gz on server1, and want to extract the archive on server2, then pipe the archive to server2 and run the extraction command there.
<archive.tar.gz ssh server2 'cd /home && gunzip | tar -xf -'
Alternatively, log in to server2, mount the filesystem of server1 over sshfs, and unpack the archive just like you'd unpack a local file.
sshfs server1:/ /tmp/server1
gunzip </tmp/server1/path/to/archive.tar.gz | tar -xf -
fusermount -u /tmp/server1