Simon Peter's reaction was inline with his previous self-trusting and impulsive nature, a tendency to rely on self to do what seemed right, rather than a faith that relied on God's promises. This cumulated to the point where he denied the Lord three times, having relied on his own abilities. It was not until the rooster struck that he finally recognized his sin and bitterly repented.
Again and again, Jesus had told His disciples that He was to be taken away and be killed, but they refused to believe, and the important significance of Jesus' sacrifice was not understood. Peter, not realizing the type of spirit that took over him, tried to even rashly rebuke the Lord for submitting Himself to such a fate.
(Matthew 16:21-23) From that time forth began Jesus to shew unto his disciples, how that he must go unto Jerusalem, and suffer many things of the elders and chief priests and scribes, and be killed, and be raised again the third day. Then Peter took him, and began to rebuke him, saying, Be it far from thee, Lord: this shall not be unto thee. But he turned, and said unto Peter, Get thee behind me, Satan: thou art an offence unto me: for thou savourest not the things that be of God, but those that be of men.
Peter's impulsive nature was also seen at the Passover dinner when Jesus reminded them of His fate and warned them that they would all scatter. However, Peter, trusting in himself, declared without hesitation that he would never desert, that he was even ready to die with Him. Therefore it was not out of character for Peter to take the situation into his own hands and try to fight the group that came to arrest and to kill his beloved Lord.
(Matthew 26:31-35) Then saith Jesus unto them, All ye shall be offended because of me this night: for it is written, I will smite the shepherd, and the sheep of the flock shall be scattered abroad. But after I am risen again, I will go before you into Galilee. Peter answered and said unto him, Though all men shall be offended because of thee, yet will I never be offended. Jesus said unto him, Verily I say unto thee, That this night, before the cock crow, thou shalt deny me thrice. Peter said unto him, Though I should die with thee, yet will I not deny thee. Likewise also said all the disciples.
We are all not without shortcomings, but the key is to recognize these flaws when revealed to us by the Holy Spirit, and by grace seek to overcome. When Jesus returned after His resurrection, the extent of Peter's repentance and the change in his character was clearly seen. When Jesus tested him, asking whether he loved Him more than the others, the previously rash Peter did not make a grand statement of devotion, but with a truer estimation of self, responded "Yea Lord, you know that I love You". (John 21:15)