A Mechanistical Study on the Formation of Dimethyl Ether (CH3OCH3) and Ethanol (CH3CH2OH) in Methanol-containing Ices and Implications for the Chemistry of Star-forming Regions