In the first image, a wave property of electrons is observed. This is quantified quantum mechanically via a wave function. Physicists think, hey, what if we can detect which slit it goes through?
The tool we use to detect electrons are photons. Since the electron is so small, the photon only lets use detect an electron by recoiling off the electron (see: compton scattering). This collapses the wave function, causing electrons to behave as particles.