In the game with Padres and Phillies, how does Lucchesi get the win while the game was tied at 2 to 2 when he left after 6 innings?
If you're referring to this game, then you can see that the winning run was scored in the top of the 7th inning. At that point, Lucchesi was still technically the pitcher as he hadn't yet been replaced -- which would happen in the bottom of the 7th. Since the winning run occurred while Lucchesi was still the pitcher in the game, he earned the win.
The official rules are a little difficult to follow in terms of scoring, but it seems like the scoring is ultimately up to the official scorer for the game. I think the final sentence from the following rule is the most relevant to this scenario. (emphasis mine)
Rule 9.17(a) Whenever the score is tied, the game becomes a new contest insofar as the winning pitcher is concerned. Once the opposing team assumes the lead, all pitchers who have pitched up to that point and have been replaced are excluded from being credited with the victory. If the pitcher against whose pitching the opposing team gained the lead continues to pitch until his team regains the lead, which it holds to the finish of the game, that pitcher shall be the winning pitcher.