Theory of phase stabilities and bonding mechanisms in stoichiometric and substoichiometric molybdenum carbide