The short answer is nothing. The offensive and defensive aspects of war tend to evolve in a leap frog fashion in much the same way that any two directly opposing forces do. Without a threat to necessitate the development of underground defenses there wasn't much drive to create them.
The best defense at the time was high walls, gave archers better range and line of sight, and it made it harder for attackers to get through. In the end defense are there to keep you protected and applying force as long as possible before the enemy is upon you. If I think about warfare at the time, underground defenses actually seem like a worse idea than what medieval Europe actually had, for example fire was a commonly used weapon...underground + fire = bad.
A fictional threat would be the only thing I can think of that would necessitate the creation of underground defenses in medieval Europe...more to the point, without that threat they would actually be less effective in medieval combat when compared to castles, towers and walls.
Flying creatures of some kind are the obvious choice; dragons, wyverns, maybe some giant Rocs.
I suppose you could go with some sort of really large land animal, I am thinking of the elephant/hammer head shark crossover from Avatar.
Giants. Really really big giants.
A magic system where the earth somehow negates powers...
Now, even with these creatures in the world they would have to be common enough that they showed up in a good portion of battles, otherwise, when its just human on human fighting castles would still be the way to go. Castle building/defense in this scenario would, I think, be mainly for hiding as opposed to castles traditionally being bastions from which to exert your local authority.
edit: Thought about this some more, and no matter what else a castle needs to allow you to fight back otherwise it is just a tomb, doing this on a flatland...I don't see that working out well for the defenders. If the castle is underground...returning fire would be pretty tough, unless its built into the side of a mountain or under a hill...like this.
So in this image, you could have an underground castle with tunnels up to the surface, if your enemies are dragons, their are trapdoors with ballista, or maybe a good old fashioned death trap for a giant (big spikes at the bottom of a hole). I still think a flying enemy makes the most sense and when I think of underground fortresses I do feel like its more hiding than just purely defensive like a castle.