A cabinet MP cannot vote against their government's wishes and retain their position as a cabinet minister. So, if an MP feels that the government's wishes no longer align with their own, they have a simple choice: abandon their principles and keep their position, or resign from the government in order to vote against the motion(s) in parliament, becoming a backbencher in the process.
Resigning from the government can also be a case of simply disagreeing with the government's general position rather than being about a single vote, which is what we've seen today in the whole Brexit thing: government ministers no longer seeing eye-to-eye with May on Brexit, and in some cases do not want May to remain as PM at all. It would be a conflict of interest for them to remain a part of the government if they do not agree with that government's wishes.