I’ve also seen traps like this in at least on James Bond and a Macgyver episode.
The booby traps put into the ancient Egyptian tombs failed terribly.
If you want a large mechanical trap to last a very long time, you want to make it out of a stable ceramic, such as quartz. Quartz is more resistant to chemical degradation than micas and feldspars. Failing pure quartz you could try quartzite or even sandstone, but only if it’s completely dry and there’s no physical erosion (eg. due to wind-blown sand). Granite does fairly well in a completely dry environment.
Good long duration lubricants are very difficult to make – most will eventually evaporate or decompose thermally. For a liquid lubricant one of the longest lasting is Krytox, a class of fluorinated greases. For dry lubricant you could try molybdenum disulphide, tungsten disulphide or hexagonal boron nitride.
For adhesives, certain specialist epoxies would hold up well.
For a flexible element (eg. rope), consider either a fluoropolymer such as polyvinylidene fluoride or an elastomer such as Nitrile rubber or Viton.
If you have the option, get rid of the CO2 and O2 in the local air. Use either nitrogen or a noble gas for an atmosphere for the longest lasting traps. Not a vacuum, the gases in the air actually act as a lubricant and without them you would get vacuum welding – which would be very bad for mechanisms of all types.
For a power source, gravity is one that perhaps lasts the longest, so you’ll see that a lot in the movies. A single large falling weight is one option. Cuckoo clocks use two falling weights.
Hero of Alexandria ran his stage scenery, which was an extraordinarily complicated group of mechanical mechanisms, off a fire powering a steam turbine, so perhaps you could get a small mechanism to light a fire to produce steam power. The limitation of using steam power as to run the complicated trap is the problem of the decay and evaporation of fuel – coal and charcoal would be two of the most stable fuels to power such a trap.
All that I’ve said above relates to mechanical traps, such as that in the Tomb Raider movie, not chemical traps such as a pit of acid or biological traps such as a nest of army ants.