You're right - it can't be a co-incidence. Nearly all paints and varnishes are toxic to small animals unless it is one of the few that say pet-safe (and I only know of Plastikote - which is water based and doesn't really smell of anything).
The problem is, hamsters chew so they would be eating the wood preservative or varnish or whatever. They also have a highly tuned sense of smell and smells can be overpowering for them. (Which is why cleaning products need to be low odour and petsafe too - I only ever use warm water, and rarely washing up liquid then a good rinse).
I think it would be wise to get a new cage. Do you prefer wood? There are some excellent hamster cages on Zooplus at good prices - good sizes for hammies. Standard cage types, but also some wood type ones.
The Barney is popular at just under £50. Suitable for dwarf or Syrian hamsters as narrow bar spacing (although it would need setting up carefully for a dwarf hamster).
Is it a dwarf or Syrian you are getting? Anyway these are all suitable for Syrians
Barney Pet Cage | Great deals at zooplus!
The Alaska is smaller but still meets minimum floor size recommendations and is about £32
Alaska Hamster Cage | Free P&P on orders £29+ at zooplus!
The Alexander has a second level and costs a bit more
Great deals on small pet cages at zooplus: Alexander Small Pet Cage
TBH if it's for a Syrian you can't go wrong with a Barney cage.
This is also suitable for a Syrian or dwarf hamster (Maxi Duna Tank).
Cage Maxi Duna Multy
For Dwarf hamsters as well there is the Kerry Terrarium - also has narrow bar spacing:
Hamster Cages: great selection at zooplus: Small Pet Terrarium Kerry
Depends how much you want to spend! There are more expensive cages and tank style cages!
If you prefer wood, someone on here has this one. It's flatpack. when you put it together you can swap the front panel so the door is at the top (allowing for deep substrate at the bottom). I personally wouldn't fancy all that painting with plastikote paint! But it's a great size.
Songmics XXL Wooden Hamster Cage Guinea Rodent House Mice Cage 115x60x58cm PHC001: Amazon.co.uk: Garden & Outdoors
Meanwhile - if there are any other things you want to know, ask away. In case there is something else that could be a cause, but it does sound like it might have been the paint.
eg. Best to leave them to settle in for the first 2 or 3 days without too much excitement. Plenty of substrate and torn up white toiet paper to build a nest with. Good hamster mix and make sure water bottle is working each day.
My Grandma had 24 budgies die on her in close succession. She was very attached to the last one and was so upset she had an autopsy done it. They had died of lead poisoning. She used to let them fly free in the room and they would sit and peck at the old leaded windows.