In Canada, and I assume the UK and similar systems, the individuals run in their constituency (riding). The ballot contains a spot for “party affiliation”. To have the party show up on the ballot, the head office for the party has to sign off on the candidate’s affiliation. While the candidate is nominally elected by the party members in the riding, this gives the central brass an effective veto - and sometimes the central office will twist arms or outright appoint someone as candidate if for example, they have a star candidate to promote (but overriding the local wishes carries its own risks sometimes). Just like in the USA, though, riding votes tend to lean toward certain party affiliations so the party endorsement can be important.
There have been numerous instances (including in yesterday’s election) where a candidate’s current or past actions of speech have resulted in the party denying or withdrawing affiliation. If this happens early enough, the party can nominate an alternative candidate, and the “guilty” candidate has the option to withdraw or run as an independent.
I would say as a rule of thumb, about half the votes in a riding are due to the local candidate, and half due to the party affiliation (i.e. support for the leader and overall policy). Generally, a person choosing to defy the party is effectively committing political suicide, saying “F*** you” to the party brass will be remembered long after the public forgets. Plus, the person is liable to split the party vote and result in the rival party winning - another “not good” mark against the person. And, in a parliamentary system, the cabinet and the prime minister are the result of the party winning the most seats - so political career is very much tied to being elected with the right party.
From what I read of the American system - the opposite. Candidacy and party affiliation come from primaries and grass roots. Plus, the legislative position carry their own weight - they don’t really lead to further positions like cabinet; about the only promotions available are to committee memberships. Local politics seems to carry a much heavier weight than in a parliamentary system, since the public can vote for leader from one party separate from their congressional or senate rep. The only blow from being “kicked out of caucus” is not getting to participate in strategy sessions. Even for things like modifying bills to add one’s particular pork - the US system is more a matter of “you scratch my back, I’ll scratch yours” so once elected, an independent’s only disadvantges would be animosity of the other party/parties, and not having a group to push a particular issue. Both of these can be overcome by a particularly persuasive politician.
So there’s really no great disadvantage for the party disavowing affiliation. About the only thing the party can do is send someone else to run in a primary against a rogue member. This presumes the consituents also give a … hoot… about the issues in play.
This is also the failing of the American system, Primaries are low-turnout votes. As a result, the fanatical and dedicated - i.e. the more radical - can have a bigger effect of the results, and those with dedicated followers can have outsized influences. The more moderate as less interested.
Then there’s elephant (and donkey) in the room - money. Unlike the Canadian system, where spending by advocacy groups can be very limited, by law - the USA is wide open. Candidates tend to raise and spend a lot of their own money on very personal campaigns, rather than a centralized party campaign that tries to float all boats.