How do you explain Hamlet's behavior toward Ophelia in act 2, scene 1?
We don't actually see Hamlet's behavior in the scene, we have to imagine his actions based on Ophelia's telling of his actions to her father, Polonius. From Ophelia's description, it seems that Hamlet has started his "crazy act" as he explained it at the end of Act 1. The normal Hamlet would probably have come to talk to Ophelia wearing clothes that fit properly; speaking in clear language about whatever topics these young lovers say to each other. But Ophelia reports that when Hamlet comes into her room he looks like a disaster: his shirt is undone, his socks aren't pulled up, and he isn't wearing a hat. These are clearly not in keeping with how he usually presented himself. She then reports that he didn't actually say a word to her, he only gave up long drawn out sighs and stared at her, never breaking eye contact as he backed out the room and out of her sight. Ophelia, and now her father, are convinced that Hamlet has a case of madness, so Hamlet's plan to act crazy has worked. Polonius is convinced that the madness has sprung from Ophelia's rejection of him, and he relishes being able to report this to the King. Hamlet' plan to working!