Matter is usually defined as something that has both a rest mass and a volume. Photons have neither of these so they are not considered matter. When something is moving very fast, close to the speed of light, it starts to gain extra mass because of relativity. This is why photons, which move at the speed of light, have mass. But if it were possible for a photon to be at rest, it would have no mass. By the way, in Einstein's famous equation E=mc2 which says that mass and energy are the same thing, the m in the equation is actually the rest mass plus this extra mass due to relativity.
This is a fantastic question! The topic of photons can be a very confusing topic even to scientists studying their behavior. Let’s start off by defining what matter is. Matter is generally something that has mass (it has weight) and volume. For example, a bus is made of matter because it is heavy and takes up space. Now, what is a photon? A photon is generally considered to be a “particle” of light, but this particle is very special. A photon particle does not have any mass (because you cannot “weigh” light), so it is not considered to be matter.
Scientists call a particle of light a photon because it can carry and pass on energy like matter can, but it also sometimes acts like a wave, as light should. Since a photon is a particle that has very unique abilities that normal matter does not have, we can say that light is not matter.