Seven-time Formula 1 world champion Lewis Hamilton will leave Mercedes after 11 years once the current season ends, having agreed to drive for Ferrari in 2025 and 2026