Because the Earth, Sun, and Moon don’t line up perfectly every month, mainly because of the tilt of the Earth. A solar eclipse is when the moon blocks part of the Earth from sunlight. A lunar eclipse is when the Earth blocks the moon from sunlight, giving it an orange-red color.
See this link if you’d like to learn more about solar and lunar eclipses. It has a couple of good diagrams as well.
https://spaceplace.nasa.gov/eclipses/en/