How do you prevent specific class scripts from transfering to all classes?
You cannot prevent this due to the way .cfg files work.
What you can do is, if a setting appears in at least one class, write the default setting to all the other class config files.
To go a step further, make a .cfg file with all those default settings and execute it at the beginning of each class config file. No further hacks will be required.
The Solution:
Make a script for each class, and place exec config.cfg
at the top of each one.
This config file contains all your default settings, and should clear any key bindings and other assorted changes.
This should unclutter your scripts quite a bit.
Important Note:
Any excessively strange settings you may have created that aren't in the 'default' setup of TF2 may not be undone by this, so you may have to include your own code to undo them.
If this is the case, make a separate config file and place the code to clear them in that file. Then, simply place exec <custom reset script name>.cfg
before exec config.cfg
in each class script.