We can say that carbon, phosphorous, nitrogen and water are matter. The matter is anything that has mass and occupies space. These ones have mass but energy does not have.We get energy from the sun. Energy through an ecosystem differs from matter in many ways. For example, energy flow through an ecosystem going in one direction that is from the sun to producers to herbivores and lastly to carnivores.
In an ecosystem, energy flow in one way while the matter is recycled. For example, the water which we drink today is the amount of water we drink today is the same water which was drunk by creatures some years back, here you can see energy is not reused but in the matter, it is constantly reused.
Energy flows in a circuit and the circuit flows in the wire which helps light to come on but in the matter is the amount of space taken up.