I appreciate me being a Brit may both preclude me from fully appreciating the situation in terms of how your elections etc work...and also, well we certainly have our own issues here that raise eyebrows (anyone for Brexit? 😡).........but.....
In Canada, the system seems stronger than in the US but weaker than in the UK. In Canada, a party leader can drive someone out of their party, but they still sit as an MP, since they were elected, and so can't be fired from that position.
In the US, a Rep/Senator's boss are the primary voters. Primaries are somewhat open "nomination meetings" that determine who will run for a party in a particular district, and the party bosses have little to no control over there. Primary voters are a
very small subset of the population, and are usually highly motivated by only one or two topics (called "single issue voters"). So a primary voter might vote for whichever Democrat running for District A is anti-gun control. (Most Democrats are pro-gun control, but in conservative areas they tend not to be.) Enough vote and that Democrat wins. Meanwhile the local Republican who won the election is also against gun control. So it doesn't matter which Rep you vote for, you get someone opposed to gun control. Single issue voters won't care if the primary candidate is a criminal, because that's less important to them than their (stated) views on religion, gun control, welfare, immigration, etc... whatever the single issue is.
More recently, Democrats and Republicans have effectively become a "tribe". So "every" Democrat has certain views, and "every" Republican has certain views, even though some of the "mandatory" views on both sides are stupid. Primary voters want the whole package; even if a voters believes that particular view is stupid, they see the view as a tribal marker. If a primary candidate goes against these mandatory views, the primary voters vote against them, picking a candidate sticking to those views.