first off 'better' is a false idea. Dinosaurs were superbly designed as top animals. They 'ruled' the planet for 250 million years, a far longer dinasty than mammals have thus far mustered.
At the time that dinosaurs became te the world was much different and mammals while successful were not designed for nce.
Mammals still had a semi-sprawling posture wich limited thier speed and manuverablility. They didn't have a metabolism advantage as dinosaurs were warm ed as well. Mammals saught refuge in being quick breeders in the dark places that the then te Reptiles held.
The Dinosaurs were also small, but they had the advantage of a fully upright posture. With their bird-like legs they could run and jump in ways other animals couldn't. They could range far and wide in search of food, water, and mates... something the mammals couldn't do nor could the Reptiles. Their speed and agility let them avoid the much larger predators like Postosuchus (who at the time was the largest land predator on earth) they were also sociable animals and found early on that hunting in groups maximized thier ability to bring down prey. (Ghost ranch for example has hundreds of Celeopysis who died together at a dry waterhole)
Their design eaventually allowed them to become the largest animals that ever lived.
In the end that may have been part of thier downfall... large warmblooded animals require more food and space than small ones. With thier environment in disarray they couldn't do what thier small bird relitives could, fly someplace new to find food. Birds could cover vast areas, small mammals can hibernate as can many reptiles like turtles and crocs. Dinosaurs apparently could not and thus they couldn't simply sleep away the bad times.
The world was going through massive changes. The great shallow central ocean was disapearing, this ocean helped control the environment of North America and other shallow seas were also dissapearing around the world. Volcanism was on the rise at levels rediculously higher than we have now. The Rocky Mountains were thusting up as a chain of Volcanos, some as we all know still active. Imagine nearly all the mountains of the Rockies exploding regularly, from Alaska to California. Similer events were going on all over the world... Europe was riseing up out of the growing Atlantic Ocean and Africa slammed into Asia as did India and Australia and Antartica were ripping apart.
Add on top of this the impact of the ilub asteroid and its amazing that 40% of life on Earth managed to survive.
Small size, the ability to hibernate and high reproductive success are all that kept the few mammals that made it through the K/T extintion from joining the dinosaurs. Remember of the 6 orders of mammals that existed in the time of the dinosaurs only 3 made it though.
Of all the orders of Dinosauria only the two groups of Aves we have today survived.
wa:do