Dinosaurs, meaning “Terrible Lizard” evolved from reptiles as their name suggests. But they didn’t evolve from proper lizards, but something closer to crocodiles.
Evolution happens very slowly over millions of years, so they did not just appear one day. One reptile might have been born with a slightly longer neck, meaning it could reach much healthier food, meaning it could raise many more young dinosaurs all with slightly longer necks. The same could have happened with a different group of reptiles so that they could run faster and catch prey. This is how their forms became so different with hundreds of different species.
Dinosaurs are a great example of evolution – as Shane said, they really took on the characteristics and needs of their environment, with some slower dinosaurs developing shell spikes to protect against faster predators, whilst others developing big long necks to reach fruit in trees! Dinosaurs had a really balanced ecosystem where they lived – imagine how they might have continued to evolve if they hadn’t all been killed!
The people who spend their lives thinking about this type of question still aren’t sure about how they came into existence. The basic idea is that over time animals develop into other creatures (evolution), but the changes are really slow. Over time fish slowly evolved (developed) into creatures that could walk on land and breath air, and then those creatures developed into dinosaurs… and humans, we stemmed from fish ancestors too that evolved into tetrapods (these are lizard like). We know that there were lots of different types of dinosaurs, so these different groups were probably made in different ways (lineages that split and evolved into different species of dinosaurs). Some of the dinosaur groups were sort of like birds while others were more lizard-like. Great question again purplebee!