tar extraction also automatically decompresses
Your tar
implementation, likely the GNU
one, is detecting the file passed as a parameter is compressed.
The mostly used tar
implementations these days, GNU tar
and busybox
ones, are looking to the first bytes of the file, a.k.a. magic number, to figure out if it is compressed and the compression algorithm to use.
The tar
implementations found on commercial Unixes that are based on the original AT&T code do not support the -z
flag in the first place. One notable exception is Solaris 11 tar
where this extension has been added, including the ability to detect the file format.