I've had the same problem.
I heard a fix to it is to crouch down (default "C") and it should fix the sliding, although the cart separating is something engine side (I think) and you can see the same thing happening in another game (Garrys Mod) where your welded parts will separate and spring back together.
At this point I've realised that the cart and mine are riddled with bugs so I avoid them completely in my playthroughs now. While it might be inconvenient, it certainly isn't game breaking which is the main thing for me. :)