Most of the normal physical matter in the Universe is either hydrogen or helium. Astronomers use the word "metals" as a convenient short term for "all elements except hydrogen and helium". This is different from the usual chemical or physical definition of a metal as an electrically conducting solid.
The heavier elements come from stellar nucleosynthesis. Most elements heavier than hydrogen and helium in the Universe ("metals") are formed in the cores of stars. Over time, stellar winds and supernovae put the metals into the surrounding environment, enriching the interstellar medium. There it is material for the birth of new stars. Older generations of stars, which formed in the metal-poor early Universe, generally have lower metallicities than those of younger generations, which formed in a more metal-rich Universe.