My understanding is that it comes from collective cabinet responsibility.
"Cabinet collective responsibility, also known as collective ministerial responsibility,[1] is a constitutional convention in parliamentary systems that members of the cabinet must publicly support all governmental decisions made in Cabinet, even if they do not privately agree with them. This support includes voting for the government in the legislature." - Wikipedia.
While this doesn't apply to MPs or, I think, shadow cabinet positions, it has created a system where a strong form of protest to show your disagreement with the party is to resign your position or membership of the party.
Another way to look at it would be as someone saying 'these decisions and actions are so abhorrent to me that I can no longer be associated with the body taking them.'