Basically, there are some knowns:
The universe expands according to the fried,am equation.
Different percentages of matter, energy give rise to different expansion rates.
Expansion history of the universe is known via looking at supernova (which are equally bright at the source).
Knowing matter is mostly hydrogen/helium and energ is mostly photons allows us to calculate the density of matter/energy in the universe. These don't match the terms found from measuring supernova leading the differences to be called dark matter/dark energy.
Additionally, gravitational lensing is seen by objects which can't be seen. Meaning, they have mass, but don't appear to absorb/reflect light. Additional additionlly, similar effects are seen affecting the formation of galaxies: extra matter is needed to give the structure we see, but we apparently can't see that matter.
So it was originally dark because we knew nothing about it, but the name stuck once it appeared we could not see it.
It is definitely matter.