The giant negative thermal expansion (NTE) found in the anti-perovskite manganese nitride could be controlled by the content of the doped Ge and the vacancies of N. In this paper, the origin of such a tunable thermal expansion behavior is systematically studied. Our calculations indicate that the doped Ge atoms enhance the NTE property of the compound, and the existing N vacancies have a weak influence on the NTE property. Furthermore, the change of the exchange parameters between Mn ions with the content of the doped Ge as well as with the N vacancies in the compound is revealed, from which the relative stabilities of different magnetic phases in the concerned compounds can be explained.