The key concept is 1,3-diaxial interaction. See the figure 1 below using methylcyclohexane as an example.
Figure 1: Equatorial and axial conformations of methylcyclohexane with 1,3-diaxial strain highlighted.
If a methyl group is in axial position of a cyclohexane ring, the angle strain-free chair conformation means that it ends up rather close to the axial hydrogen atom two carbons along the ring. This steric strain is depicted in the axial case with the inverted brackets. In trans-1,2-dimethylcyclohexane, the di-axial conformation would introduce this strain into the equation twice, destabilising the molecule.
Now you might want to argue that including a second methyl group into the depictions below would cause other types of strain to appear and you would be correct. In the di-axial conformation the two methyl groups are anti-to one another while the di-equatorial configuration has them gauche. However, realise that the cyclohexane ring also exists. Each methyl group in the di-equatorial conformation is gauche with respect to the other methyl but anti with respect to the cyclohexane ring. In the di-axial conformation, each methyl group is anti with respect to the other but gauche with respect to the cyclohexane ring. (See figure 2 below.)
Figure 2: di-equatorial and di-axial conformations of trans-1,2-dimethylcyclohexane with 1,3-diaxial strain highlighted for both methyl groups.
Comparing it in that way shows that the strain between the methyl groups and the ring remains more or less the same in both cases. Probably having the two methyl groups anti would be slightly preferred as the ring is conformationally less flexible and would thus induce marginally less strain. However, the clear driving force here is 1,3-diaxial strain which only occurs in the diaxial conformation.