How is it possible that whenever Harry wanted to visit Dumbledore's Office and he threw a wild guess at a password, he always got it right? Of course, it is out of the question that anyone with good intentions would be allowed in because, as we know, Dumbledore told Harry that the password was 'Acid Pops' in HBP. Is there any info on this matter?
Harry doesn't always guess the password. For example, In Goblet of Fire, Harry races to Dumbledore's office after finding Barty Crouch cursed and babbling in the forest, and he guesses Sherbet Lemon, but that is no longer the password. (GoF - chapter 28 - The Madness of Mr Crouch) Later in GoF, Harry guesses the password to Dumbledore's office (Cockroach Cluster) but says himself he was only joking when he blurted it out, and was surprised when it worked as a password.
In Chamber of Secrets, Professor McGonagall says the password in front of Harry (Sherbet Lemon). I can't find anything in Prisoner of Azkaban that has Harry visiting Dumbledore in Dumbledore's office at all; Dumbledore chats with Harry at the end of the book in the DADA classroom office. Please correct me if I am wrong. In Order of the Phoenix, Professor McGonagall is again the one to say the password in front of Harry (Fizzing Whizbees) after Nagini attacks Mr. Weasley in the Department of Mysteries and she is taking Harry to Dumbledore. In Half-Blood Prince, Dumbledore himself gives Harry the password in his note to Harry: PS: I enjoy Acid Pops. In Deathly Hallows, Harry desperately grabs at "Dumbledore" as a password. It makes sense that the password would be Dumbledore; many in the castle were still loyal to Dumbledore after his death, and of course Harry was Dumbledore's man. And Snape, the current occupant of the headmaster's office, was loyal to Dumbledore as well.
So I don't think Harry has password ESP -- he is given the password almost every time. Otherwise, he has one lucky guess ("Dumbledore!") that's understandable considering the circumstances under which Harry is at Dumbledore's office to begin with, and one plain lucky guess ("Cockroach Clusters!")
Harry knew from past experiences with Dumbledore that the password is always a sweet that the headmaster loves, so he usually tries out all the sweets he expects Dumbledore to like, and when he gets desperate he tries other sweets (i.e. Cockroach cluster).