Messi had a really subpar season compared to his previous but what you're doing is not really a representation of who had a better season. Ronaldo since joining Juve has been playing as a 9 (striker) moving around the box and his focus being mainly scoring goals. He doesn't drop that deep neither is he involved in the buildup. He is the finishing factor. On the other hand, Messi, while still having subpar season, was playing as a winger and shifting most of the times to the center, often helping the midfield progress. His role wasn't only scoring goals, his playmaking abilities were often explored by mbappe and if mbappe had a better finishing, messi would have ended the league with more than 25 assists.
TL:DR Messi and Ronaldo play different roles nowadays, judging them based on only one metric (goals) doesn't really paint a full picture.