Here are my thoughts on how it happened, though the theory is not original:
Voldemort went to Godrick's Hollow with the intention of turning an object into a horcrux. Either he had the object with him, or he expected to find an object of Griffindor's at Godrick's Hollow. He had been intending to use Harry's death to create his final horcrux in the object. But when his avada kedavra bounced off Harry, the piece of his soul that was supposed to go into the object somehow went into Harry instead, by mistake. We don't really know how the horcrux spell/curse works, but this is at least conceivable that the horcrux could have been misplaced due to an avada kedavra killing the wrong person. I don't think the Slughorn scene rules out this possibility of Voldemort accidentally making Harry the horcrux.
As for Voldemort's attempts to kill Harry, Voldemort was trying to kill Harry that night at Godrick's Hollow, and tried to kill him several times after that as well. But only until he learned that Harry was a horcrux, which would have been when Voldemort tried to possess him at the Ministry in Order of the Phoenix. Note that after that, Voldemort shifts gears and goes after Dumbledore instead, as well as apparently instructs his death-eaters not to touch Harry.
EDIT: I guess I should cite to Mugglenet.com's book "What Will Happen in Harry Potter 7," since some I gathered some of this from that book. Ha. Who's the biggest Harry Potter nerd now?