Why the Mavs do this:
After trading DFS, who is their only good defensive player, they need more defense. Deandre Ayton is a solid rim protecter that also averaged an 18 and 10 double double last season. Ayton would also potentially have a greater role on the Mavs, as he will be able to catch lobs from Luka and Kyrie (if he returns in this scenario), and anchor the defense.
Why the Suns do this:
Ayton has performed poorly in the playoffs in back to back years and is stuck on a max deal. With this trade, the Suns get a replacement center that is a much worse defender, but would save $16 Million in the first season of his contract over Ayton's. They also get a half decent forward to make up for their lack of depth that peaked at 41% from three, and a 1st and 2nd to recoup from the KD trade.