Understanding Selectivity for the Electrochemical Reduction of Carbon Dioxide to Formic Acid and Carbon Monoxide on Metal Electrodes