I did a Time Machine backup on my Macbook running OS X 10.5.8. Then I installed Snow Leopard and tried to restore all apps, files etc. using Time Machine but it restored the system back to 10.5.8.
How can I do this keeping Snow Leopard?
The best way to avoid this is to do an upgrade from Leopard to Snow Leopard rather than an erase and install. Snow Leopard shouldn't give you the option to erase and install, it should automatically upgrade. Are you erasing your hard drive before installing Snow Leopard?
By default, Time Machine backups retain all system software, including your OS. If you want to disable this, try this:
In the future, this will prevent Time Machine from backing up system data, but it will still back up your personal data and applications.
For your current predicament, you'll need to do a standard install of Snow Leopard instead of erasing the hard drive first.