It really comes down to professionalism, and everyone knowing that it is a cutthroat sport. Most of the time, it's not personal. Also, in Sainz's case, he's effectively auditioning for a 2025 seat this season, so it is in his best interest to put in the best performance he can. It's not hard to find oneself without a seat, no matter how deserving you may be -- there's only 20 to go around. Checo was going into the off season without a ride after scoring podiums and a race win at Team Force Stroll right before he was hired by Red Bull. Getting into F1 is tough. Staying there is even tougher. I'd love to see Alonso drive for Merc.
Dan, if I had to guess, I'd say that there was probably a "Ferrari" clause in Hamilton's most recent contract, whereas if he was somehow able to procure a ride with Scuderia Ferrari, Mercedes would let him out of his contract a year early. As for the "what if" questions, he is not some unproven rookie; this is Lewis Hamilton we are talking about. He's probably one of the last drivers on the grid I'd worry about developing some sort of substance abuse issue at this stage. As for why he would try and be competitive, he is desperately trying for his 8th championship (which would put him alone at the top of the record books), as well as pad his pole and win totals so that he is hopefully never passed in any of those categories, either.