I thought what happened was Bran warged into him in the past and then sort of programmed/hypnotized him (hence the seizure) to be ready to act in that situation, and that it was Hodor himself "executing the program", so to speak. It doesn't seem like many people see it that way, though.
– Todd WilcoxMay 24 '16 at 12:17

2

As I understood it, Bran facilitated young Hodor(Wyliss?) warging into present time Hodor. Previously whenever fighting occurs we have just seen Hodor freak out but this time with his young consciousness inside him he is able to compose himself and "hold the door" as instructed. I think he is giving his life for his lord/friend/companion as you put it. In doing so he literally witnesses his own death and this causes him to mentally break down into the Hodor we are used to seeing. Again, that's just how I understood it.
– BigTallJoshMay 24 '16 at 12:51

A theory I read today said that because Bran isn't fully trained yet, he stills needs a conduit to the present in order to control things in the present. As such, when the Three-Eyed Raven was alive, he was able to control Hodor in the present by using the TER's connection to the present. When the TER died, he needed a new conduit to the present to control Hodor, so he used young Hodor. This is why Young Hodor didn't see Bran or be affected by him until the TER died.
– SGRMay 24 '16 at 13:55

and Bran wargs into Hodor which can be told from the fact that we can see the whites of the eyes of the latter for a brief second. Immediately after that Hodor grabs Bran's sledge and they start escaping.

It seems that we cannot tell for sure if Bran was still warged when Hodor was holding the door, but since there was no sign of Bran leaving his body he most probably was.

Additionally, according to GoT Wikia Bran warged into both present-day Hodor and young Hodor:

Bran hears Meera's cries to warg into Hodor and the Three-Eyed Raven
tells him to listen to her. Bran wargs into both the Hodor in the cave
(present day) AND the Hodor in his vision (past).

If this was the case then young Hodor's epileptic seizure was due to Bran being warged into him. Since it was still occurring when present-day Hodor was holding the door it would mean that Bran was still warged in both of them.

Yeah, this created a fluctuation and caused the Hodor from the past to have seizures as the present Hodor and past Hodor somehow got interconnected through Bran's vision/warging. And as Bran controlled the oresent Hodor, the past Hodor just fell onto ground
– Deepak KamatMay 25 '16 at 2:58

Did the fact that Bran was responsible for not only his death, but
also his simple-mindedness change your idea about the nature of their
relationship?

No it doesn’t. Although Bran was responsible for the whole chain of
events that killed Hodor, Hodor didn’t have to hold that door. He
wasn’t being warged into at that stage. It was Meera who asked him to
hold the door, it wasn’t Bran. He wants to protect the little guy.
That’s all he’s ever done. He wants to help — this is the ultimate
helping hand here. I just think he would be happy they could continue
without him.

But We can argue that someone suffering from lower mental capacity can't willingly and knowingly give his life like this though. Did Hodor do this knowing that he would die? Did Hodor understand what death means? That's a philosophical question beyond us.

The typical physical reaction for Bran warging into Hodor is Hodor's eyes turning white for a second before they return to normal. Here's a similar scene in an earlier season as evidence. youtu.be/qlSZZdDrKFw This suggests Hodor was not consciously in control when he was holding the door.
– ricosrealmJul 31 '17 at 21:25

There is no doubt that Bran warged into Hodor in the present to defend himself because Hodor's eyes turn white.

Another proof is that Bran simultaneously warged (by mistake) into Hodor from the past, that's why Hodor can see him.

The mental order Bran gives to Hodor in the present days ("hold the door") needs to be very powerful because Hodor knows he is going to die. Bran needs to destroy any desire to flee in Hodor's mind. In fact he destroys any other thought than Hold the door, but this mind alteration also occurs in the past and make Hodor as we know him.

I think the above poster has pretty much nailed it I would just alter it a bit. Hodor's eyes go from white to normal almost immediately. I think Bran somehow caused past and present hodor to switch places. He put past Hodor into present Hodor's body, I suppose because something else is happening in that vision or in his becoming the three eyes Raven that he can't remain in Hodor he has to remain in the vision therefore out of necessity he put the the past non "simple" Hodor into present Hodor so he'd have the mental falcultiea to do what needed to get done

I think while Bran was greenseeing the past Hodor event, he here's the 3ER say, "listen to a friend". So he then wargs into Hodor in the past and present. We see past and present Hodor's eyes turn white for a second or two. While this is happening the knight king enters the cave and kills the 3ER but just before the 3ER's actual physical body is killed he wargs into Bran while Bran is warged into Hodor. So in actualality the 3ER steals Bran's phisical body leaving Bran trapped in Hodor. Thats why Hodors eyes go back to normal. Its actually Bran's consciousness in Hodor. You can actually see Hodor while he's holding the door making grimissing faces that real Hodor would never make. So i think that present day Hodor's consciousness went back to the past Hodor and Bran's consciousness was in Hodor. That means that Bran died when Hodor was killed holding the door. The real Bran is basically dead. The 3ER that was in the tree is in Brans Body. When Meera said you died in that cave Bran, she was right. We all know that Bran is emotionless ever sense this event to9k place. It because hes not Brandon Stark he is who ever the 3ER raven is (Brynden Rivers possibly). Summer also died in that cave too so i believe the real Bran is dead. For the most part when any of the starks dire wolves die it means they are gonna die. Rickon (Shaggy Dog), Robb (Grey Wind) and Bran (Summer). I Know that Lady was executed by Ned and Sansa is still alive but i believe that this means the eventual death of Sansa. She is living on barrowed time. Now only Aryia (Nymeria) and Jon (Ghost) are still alive and I believe will survive the entire series. To add to this theory (Tin foil) I also believe that Hodor (Brandon) could still be alive. When Hodor was holding the door towards the end i paused the video and can see a wights hand or quite possibly Benjen's hand or maybe even a COTF's hand stab Hodor in the heart with a dagger. Its possible the dagger was made out of dragon glass. If it was it would stop the magic from completely turning Hodor (Bran) into a whight. I think the knight king is trying to kill the 3ER and the rest of the COTF to break the spell he's under. If he can kill all them it will end the magic that is keeping him who he is. He is comming to kill Bran (3ER) and the COTF that are living at the Gods eye. The Night King might not be totally bad like we all think. He just wants to end his misery of an exsistance that the COTF created of him.