We vote for those MP’s based on a manifesto from their party that is decided in large by their leader at the time. If that leader changes and decides they’re going to run things their way then they no longer have a mandate from the people to run the country.
It should be made law that there has to be a general election within 3 months of a change of prime minister.