The first analog computer invented was the Antikythera Mechanism, about 2000 years ago. One sample was found in an ancient shipwreck about 1910. It was designed to calculate astronomical positions for navigation.
The first digital computer invented was the Analytical Engine, about 200 years ago. It was never built. It was entirely mechanical and intended to be powered by a steam engine. It was fully programable and general purpose with an architecture very much like modern electronic digital computers.