Comparison with presidents is misleading because the prime minister does not have the same powers as a president.
It's more like Pelosi and the senate majority leader deciding to stand down in a couple of years, and the Democrats choosing someone to replace them.
In Britain we don't, technically, vote for our government. We vote for representatives, who form a government and opposition amongst themselves.
As I understand it, US congressional voters vote for a representative, who is free to switch sides, support a different candidate for speaker, etc, in a similar way.
Yes, it's unusual in British politics, but it does happen from time to time.
It's not actually that unusual. Since WW2, Eden handed over to MacMillan mid term, MacMillan to Douglas-Home, Wilson to Callaghan as you noted, and Thatcher to Major. That's at least 4 mid term handovers in 50 years, and there may be more I've missed.