Most of the time, in the US the role an official is written down in laws or the constitution.
The Office of Prime Minister of the United Kingdom does not actually exist in any written down law or document.
It’s all just a series of traditions that makes that particular Member of Parliament more important.
The average UK citizen does not vote someone to be Prime Minister, the vote on the candidate (usually put in a very safe seat), and the party chooses.
Since the Prime Minister does not have any laws giving them special powers over a normal member of parliament, if the party decides they don’t want the Prime Minister to be Prime Minister anymore, there’s nothing they can do to stop it.
Mostly they just resign and save themselves some embarrassment.
Latest Answers