The Democrat establishment wants power and for that they have to win elections. So having an anti establishment candidate is preferable to them over a Republicans victory. If anything good came out of the last election, it is that Trump as horrible as he is can still win elections against an establishment Democrat, so the Democrats have to change.
Also changing the parties does not work. The problem is systematic and the US really needs to change its election system, to get better politics.
They switch candidates in the middle of the campaign, because Biden’s polling was that bad.