Ab initio theoretical description of the dependence of magnetocrystalline anisotropy on both compositional order and lattice distortion in transition metal alloys