While it is true (as a previous answer has pointed out) that sometimes Harry was startled awake before he would have had a chance to open the door, that appears to have just been coincidental. He had the dreams almost every night and until that session with Snape he had never been able to open the door, even when he wasn't startled awake:
What was more, he was now dreaming about walking down the corridor toward the entrance to the Department of Mysteries almost every night, dreams that always culminated in him standing longingly in front of the plain black door.
I believe there is a simple explanation as to why he suddenly was able to open the door. First, though, we must note that he was able to open the door in subsequent dreams as well, for instance:
He had fallen right into the corridor leading to the Department of Mysteries. He was speeding toward the plain black door... Let it open... Let it open...
It did. He was inside the circular room lined with doors... He crossed it, placed his hand upon an identical door, and it swung inward...
So it appears that there was a turning point in Harry's dreams. Up until the session with Snape he had been unable to open the door; from that session and on he was able to open the door.
So what changed?
The answer is, I believe, that Voldemort changed. The key passage here comes from the end of the book, when Lucius Malfoy explains about the prophecy (my emphasis):
“Dumbledore never told you?” Malfoy repeated. “Well, this explains why you didn’t come earlier, Potter, the Dark Lord wondered why —”
“— when I say go —”
“— you didn’t come running when he showed you the place where it was hidden in your dreams. He thought natural curiosity would make you want to hear the exact wording...”
I think Lucius was saying that Voldemort deliberately showed Harry the place in his dreams in order to get him to come retrieve it. However, this deliberate showing was a late development.
For the first half of the year Voldemort did not realize that he had a mind connection with Harry. As such, everything that Harry saw was unintentional from Voldemort's perspective; Harry was simply seeing what Voldemort's mind was preoccupied with.
This is explicitly stated by Snape during the first Occlumency lesson:
“It appears that the Dark Lord has been unaware of the connection between you and himself until very recently. Up till now it seems that you have been experiencing his emotions and sharing his thoughts without his being any the wiser. However, the vision you had shortly before Christmas —”
However, when Harry saw the attack on Mr. Weasley, he penetrated far enough into Voldemort's mind that Voldemort found out about the connection. This too is stated by Snape during the first Occlumency lesson:
“It is enough that we know,” said Snape repressively. “The important point is that the Dark Lord is now aware that you are gaining access to his thoughts and feelings. He has also deduced that the process is likely to work in reverse; that is to say, he has
realized that he might be able to access your thoughts and feelings in return —”
It was only from this point on that Voldemort was able to use the connection to manipulate Harry, because it was only from this point on that he knew about the connection.
Now Voldemort obviously knew what the Department of Mysteries looked like, or else Harry would never have been able to get past the door. However, during the time before Voldemort realized there was a connection, the door never opened because that is what Voldemort's mind was occupied with. I.e. he was trying to find a way to get into the Department of Mysteries. What lay beyond the door was irrelevant to his thoughts at the time. All that mattered was getting through the door.
When he realized there was a connection he was no closer to being able to get through the door. However, at that point he realized he could use Harry by playing to his curiosity. Merely seeing a corridor with a door at the end would hardly be enough too get Harry to do anything foolish, so Voldemort upped the ante. He began showing Harry what lay beyond the door, giving him very specific looks into the Department of Mysteries so that Harry would be able to figure out how to retrieve the prophecy, as in this dream:
Last night he had once again made the journey along the Department of Mysteries corridor. He had passed through the circular room, then the room full of clicking and dancing light, until he found himself again inside that cavernous room full of shelves on which were ranged dusty glass spheres...
He had hurried straight toward row number ninety-seven, turned left, and ran along it... It had probably been then that he had spoken aloud... Just a bit farther... for he could feel his conscious self struggling to wake... and before he had reached the end of the row, he had found himself lying in bed again, gazing up at the canopy of his four-poster.
It just happened to be that Voldemort's plan didn't work so well, as Lucius acknowledged, because Harry didn't know about the prophecy to begin with.
So in short, there was nothing special about the particular session with Snape that allowed Harry to open the door. It was simply that up to that point the door had never opened because Voldemort, not realizing that Harry was watching, didn't care what was beyond the door. It was only once he realized that Harry was watching that he began to deliberately show Harry what was beyond the door.