Why can you graft two unrelated cacti successfully, but you cannot do this on garden trees?
Firstly, different genera of trees can occasionally be successfully grafted. For example, quince, genus Cydonia, may be used as a dwarfing rootstock for pear, genus Pyrus.

However, it is true to say that this is the exception rather than the rule. 

In the case of plants in the family Cactaceae, I would suggest that grafting is usually successful for two main reasons:


Genetic similarity. Plants in the family Cactaceae while known to be morphologically often very different, have relatively little genetic diversity. This will increase the likelyhood of a successful graft.
Ease of aligning vascular cambium. This is required for a successful graft, and in Cacti this is quite easy to achieve since the cambium is clearly visible when you prepare the scion and stock.


It is also possible that Cacti readily form callus tissue, which would also aid in the grafting process.

Nyffeler, R., 2002, doi: 10.3732/ajb.89.2.312 Am. J. Bot. 1 February 2002 vol. 89 no. 2 312-326