To say the least, Hamlet is a complicated young man.
When we first meet Hamlet, he has returned from the Protestant University of Wittenburg. It might be that the young prince prefers the academic world to the world of the court. He is a man of thought rather than action.
It would appear that he loved his father deeply and is thus deeply affected by his death . In Act I, scene 2, he says "So excellent a king, that was, to this / Hyperion to a satyr,...." He despises his uncle. He can't understand why his mother married him and so quickly after Old Hamlet's death. He is not called the melancholy Dane without reason.
Once the ghost informs him of his murder and charges him with avenging his death, Hamlet's life changes and his dilemma begins. If he were a man of action and not a Protestant, believing revenge lays in God's hands, he would have taken his sword and run Claudius through at the first opportunity. But Hamlet is not a man of action until he is positive of the correctness of that action in his mind. He thinks before he speaks, and he thinks before he acts.
Hamlet lives in a Catholic world but is a Protestant, so he cannot just kill Claudius without losing his soul, though cultural tradition makes his father and slain King hold to revenge as justice. He must first test the information given to him by the Ghost that looked and sounded like his father but may have been something else. Was it the devil tempting him into committing a mortal sin?
If the Ghost's information proved to be true, then he needed to know just how to accomplish his task without imperiling his own soul. He decides to feign madness in order to gain information. It is a good plan, or is it? Does he actually become mad in reality?
One of the major problems he has is that he doesn't know whom to trust. His only confidant is Horatio. The world of the court is a very deceitful world, and Hamlet must constantly watch his step. Perhaps the strain of all this leads him to real madness.
Polonius dies when Hamlet, in a fit of blind fury, stabs him while Polonius is hiding behind the arras. Was this the action of a sane man? He later changes the King's letter to England and orders the execution of Rosecrantz and Guildenstern who have been duped by Claudius into betraying Hamlet. Ask again if these are the actions of a sane man. Then, in the final scene we have Laertes, Gertrude, Claudius, and, of course, the Prince himself, all dead directly or indirectly as a result of Hamlet's actions.
He is a man of intelligence, humor, and education. He is also a man with a strong sense of duty. As a result of a number of things happening, he seems to become more and more paranoid; whether it is real or feigned madness is an open question. The answer to who Hamlet is, is a complicated answer.