Flat-band-induced superconductivity in synthetic bilayer optical lattices