In the case of the Antikythera mechanism, it turns out the knowledge and technology weren't entirely lost. There's a fairly well-established throughline now from Babylonian observation-based astronomical tables to Greek philosophical views and mathematics (and craftmanship) to Arabic astrolabes (retaining some of the gear-train tech) and then back to Europe, to the monastic astronomical clocks. Then the escapement was invented and added in, and boom you got modern industrial technology.
There are a lot of loss and bottlenecks along that journey, though. And many notable locations, installations and individuals. The history of instrument-making and how it is intertwined with philosophical and religious views on the skies and the topology of the universe is quite fascinating (e.g. the motivations for observing the sky, being able to produce predictions at all, crafting models, etc).