How does Time Machine work? I want to do a fresh re-installation of macOS High Sierra 10.13.6 on my computer. To do so:


I uninstalled all unwanted apps.
Backed up my computer with Time Machine.


First question

After reinstallation when I use my backup to restore my files and settings, will it restore any unwanted files such as: preferences, directories and leftovers from apps that I had deleted or will Time Machine exclude them and not transfer to my freshly reinstalled macOS?

My second question

Does Time Machine backup caches, temporary files, directories and other similar stuff, which can be generated again without any harm ?

I've been searching a lot recently but I haven't found a clear and conclusive answer.
To avoid a long and fastidious answer: 


Time Machine is duplicating (incremental backup) your root folder, i.e. /.
However, you have the ability to exclude folders from the backup (see: macOS Sierra: Exclude items from a Time Machine backup
The answer to question 2: caches and temporary files are not backed up. They are a part of the default exclusion list of Time Machine. You can see the full exclusion list here: /System/Library/CoreServices/backupd.bundle/Contents/Resources/StdExclusions.plist. 
The answer to question 1: Time Machine backups folders as Applications Support, Preferences. So, to be short: if you consider that removing an app == moving  in the Trash folder, then you will restore all the files spread on your system by the apps you "deleted" before your last backup. If you deleted them properly by removing the .app and all the linked files spread on your system, you will end up with a clean system.