The game you're describing, where you begin in the medieval era and advance through the ages toward the future while building armies to assault enemy castles, is Age of War. Both the original Age of War and its sequel, Age of War 2, fit that description perfectly, blending base-building, unit evolution, and side-scrolling battles across history.