Towards molecular understanding of local chemical environment effects in electro- and photocatalytic CO2 reduction