Has evolution made a mistake with prehistoric animals?
There are two questions here.

Dinosaurs were larger because their basic anatomy is better at being large than mammals. Their spine is better braced (no lumbar region), their breathing mechanism scales better, and their hip structure is stronger. This is called a preadaptation, or when an organism or group of organisms just starts with a head start on a particular adaptation due to unrelated reasons. It is the same reason mammals are the only terrestrial vertebrates to have echolocation: they are the only group with advanced amplification equipment in the ear to give it a head start.
Any era has its giants. Today is the time of the largest whales, largest trees, largest frogs, and largest horse to ever exist. Size is often a decent advantage: it makes you more resistant to resource fluctuation, it's just not a good for surviving global mass extinction inducing bolide impacts.

Evolution has no foresight. Evolution often produces and locks in counterproductive adaptations in the long run; while an adaptation may be an advantage in the short term, it may lock the organism into a disadvantaged position in the long run. 
Sexual displays are a classic example: some quirk in peacock brains meant early female peacocks really liked more flamboyant males, that drove peacocks to the point modern males are incredibly vulnerable to predators and can barely fly due to carrying around huge superfluous tails. Both males and females would be better off preferring/having something less detrimental, but a feedback loop has locked in that detrimental feature. Males without it can't find mates, and females who do not prefer large tails male offspring also can't find mates. The term for this is fisherian or runaway selection. As an another example of counterproductive selection, many organisms when no longer controlled by predators or other factors will expand their numbers and consume resources to the point their populations collapse because there are too few resources to sustain them. Parasites often face this: a host with too many parasites dies, which is bad for the parasites but if the host can't fight off the parasites many are perfectly happy to kill their host and then starve.

Another aspect of evolution not having foresight is it cannot prepare you for extremely rare events, like mountains falling from the sky.