X-ray spectral states and metallicity in the ultraluminous X-ray sources NGC 1313 X-1 and X-2