The first person claims that the fruit belongs to him – they are the produce of his trees.
The second person claims that the fruit belongs to him – it was his land that supported their growth.
In this case, according to the Mishna, they must split the profit from the harvest.
The Gemara on the next daf rules that this halakha is true when the trees were washed away with a significant amount of soil, which allows the fruit to be harvested and used immediately. If the soil was lost and the trees are viewed as freshly planted, then for the first three years the fruit would be forbidden because of orla (the prohibition to derive benefit from the fruits of the first three years – see Vayikra 19:23). It is during those three years that the fruit is viewed as a joint effort.
Once those three years have ended, the owner of the field can lay claim to the entire harvest, since he can argue that by this point he could have planted his own trees and been allowed to harvest them. Of course, in such a case, he would have to purchase the trees from their owner.
What if the owner of the trees did not want to sell them, rather he wanted them returned? The baraita teaches that he cannot demand to receive them, and Rabbi Yohanan, one of the great amora’im of Israel, explains that it is mishum yishuv Eretz Yisrael – in order to support the settlement of the Land of Israel. We do not want to be responsible for the uprooting of trees that are already rooted in the land, and it is likely that the owner of the trees will replant them in land that was already set aside for this purpose.