A dark matter solution for the XENON1T electron excess and the galactic center 511 keV line