What is the reason that .tar.gz files have two extension instead of one?
From what I understand this type of file is an archive just like RAR files are.
Not quite. Back in ye days of yore when CPU time was very expensive archives were often uncompressed or used the compression hardware on a tape drive. The tool usually use for this was tape archive.
Unlike what the name seems to suggest, it can write the archive to any file (and on Un*x a tape drive is just like a file). So creating a non-compressed archive is easy.
If you want to compress that then you can first create the archive (with all its files and folders) and then compress your archive.tar with something like compress. Compress adds a .Z suffix so you then have a file with two extensions. (archive.tar.Z).
In time compress was replaced with gzip (and the .gz extension) and many versions of tar can do this compression in place.
Rar (and arj, lha, zip and others) are way more modern and compress files in place. In which case you use one single program and you get one single extenstion. But for tar the extensions and the create whole archive and then compress the whole archive are a result of history.