Tumor cells can have very unstable genomes, as much of the error repair machinery is damaged or missing. Since the cells are rapidly dividing and the DNA gets duplicated each time a cell splits, more and more mutations accumulate as the tumor grows and metastasizes. Just like in evolution as a whole, mutations that are either neutral or help the cell survive better in its environment are kept, whereas cells that develop deleterious mutations (perhaps killing the cell outright, making it more visible to the immune system, or just giving it a growth disadvantage as compared to neighboring cells) either die out or get outnumbered by other cells. This is why, over time, tumors can become resistant to therapies intended to kill them, as their cells accumulate mutations that help it evade the treatment and keep growing. There may be a disadvantage that the cells might grow more slowly than the original ones, but since the original ones were killed by the treatment, the resistant ones survive. So, this means that a tumor is rarely homogeneous, with all the cells having the exact same genome. Deep sequencing using next-generation methods is being used to gather information on all the different mutations throughout a tumor, which can help doctors learn which mutations are most common and prescribe patient-specific combination therapy which can kill all the various cell populations at once.
So why are metastatic and xenografted tumors different from the parent? Metastases can arise from single cells or very small clumps of cells, and xenografts are generally made with very small pieces of tumor, so both may start with a different set of mutations than is common in the original tumor. As they grow and divide, as described above, they will become different from their parents. The surrounding environment definitely affects this: the amount of oxygen present, degree of vascularization and blood supply, number and kind of immune cells present, etc. With all these and more factors, a metastasis or xenograft will evolve differently than its parents.