https://en.wikipedia.org/wiki/K%27Nex
Capsela and K'Nex were both great. I absolutely loved capsela as a kid. Capsela was an incredibly satisfying toy to play with and it was simple to put together. Relatively small changes created significantly different machines. Understanding the toy made it more fun to play with, but it was fun with almost no understanding too. Playing with it increased understanding.
This is not from experience, but what I expect the answer is for older kids:
A 3d printer with help understanding how to mechanize is probably best.
Adafruit is probably one of the better websites for acquiring interesting parts:
Maybe what you're looking for: https://www.adafruit.com/category/227
It's hard to give a better answer without knowing age/budget/goal/etc.