Not much of a trick, the first tar serializes the entire directory structure including all the metadata into a stream of bytes, from which the second tar reassembles it.
Basically the same as tar's standard usage, except you don't store that stream as a tar file/image anywhere.