We investigate the energetics involved in the tension and compression twinning deformation processes in magnesium via first-principles studies. Through identification of structural changes associated with each deformation process, we study the energetics of each deformation process and the local instability in the twin boundary region. We observe that the energy barrier in the compression twinning deformation pathway is higher than that in the tension twinning deformation pathway, even though the compression twin boundary is more stable than the tension twin boundary. We extend our study to examine the effects of Y and Li as alloying elements on each twinning deformation process. Our calculations predict that the addition of Y causes a reduction in the probability of fracture by an order of magnitude when the twinning deformation occurs and weakening of the resistivity to twinning deformation. However, the effect of Li addition on the twinning deformations is weaker than that of Y addition.