Weidman was quite literally raised to beat him. When Anderson made his debut as a professional, Weidman was 13 years old. By the time Weidman made his professional debut, Anderson was already three years into his dominant championship reign. By the time he reached the UFC, Anderson had completed nearly a five year stretch as champion.
Weidman knew that Anderson was the man to beat in his division, and had certainly been studying him loosely since at least his professional debut in 2009. He had studied all his tricks. His taunting, his feeling out process, his strengths in the clinch, his weaknesses on the ground, his unintended openings, his bait counters.
Anderson, for his part, I guarantee didn't even know who the hell Weidman was until at least 2011. Maybe even 2012, after the Maia fight.
Combine this with the fact that Weidman was always a stylistic nightmare for Anderson with the threat of the takedown, it was a recipe for disaster. Anderson had no magic that night, Weidman didn't believe in his tricks anymore.
TL;DR: Weidman's years of preparation, studying, and grappling threat combined with Anderson's years of dominance exposing nearly all of his tricks lead to his downfall.