Fish has gills to extract oxygen from water, not from air.
But sometimes it wiggles into air from water and gets back before its too late.
Why does he do that?

Many fish can also breathe air  - at least to some degree. This is seen in lungfishes, anabantoids (gouramis, bettas etc), and gas exchange can also occur through skin to some extent. See here for eaxmples:

The functional important of these abilities varies among species but being able to breathe air can mean individuals can survive in stagnant pools with low oxygen (some gouramis), travel overland when needed to facilitate migration (eels) or exploit patches of habitat other fishes cannot  (mudskippers).