A few years ago I experienced a very strange (to me), and quite frightening disturbance in pitch perception -- one that came out of the blue. Fortunately it was temporary, lasting not much more than 24 hours. This may not apply directly to your situation, but is a possible answer to your question 3 (What other circumstances could affect the perception of the accuracy of the pitch adversely?).
I habitually wake to the radio, and my bedside radio is usually tuned in to BBC Radio 4 (a popular, national spoken-word radio station in the UK). This features a "time signal" in the few seconds leading up to the start of each hour -- colloquially known as the pips. The pips comprise a short sequence of pure tones.
One particular morning, the radio had been on for perhaps ten minutes, but there was something wrong. It seemed as though the station wasn't quite tuned in to the right FM frequency, because certain voices (notably only those of the female presenters) sounded distorted. I tried adjusting the tuning, but this had no effect. Then when the pips sounded, they were clearly very distorted -- more obviously so than the voices of the presenters. I was frustrated that I couldn't fix the problem there and then, but didn't think much more of it.
About an hour later, sitting down at my digital piano (using headphones), I started some practice, and immediately realised something was wrong. None of the individual notes sounded right. All were distorted to some degree, but this was far more noticeable with the higher pitches. It didn't take me very long to work out what was going on -- for any given single external tone, I was hearing a different pitch in each ear!
I didn't precisely quantify the pitch difference, but it was a shift of the order of half a semitone between my left and right ears. That explained why the radio had sounded as though it wasn't properly tuned in -- especially for pure tones such as "the pips". I was hearing any given single auditory stimulus at two slightly different frequencies simultaneously, which were then "beating" against one another, and giving rise to distortion.
And the cause? I was suffering from a particularly nasty bout of sinusitis at the time, much worse than I'd ever experienced before. My assumption then is that it was likely an ear infection related to the sinusitis that had suddenly affected pitch perception in one (or possibly both) ears. This condition is known as Diplacusis, and the Wikipedia page describes ear infection and "acoustic trauma" as possible causes. Acoustic trauma can no doubt be caused by excessively loud music.
Fortunately, the effect gradually wore off during the day, and had fully resolved by the following morning. I did however find it very disturbing that a sense (pitch perception) I'd assumed to be completely "reliable", could suddenly start playing such profound tricks.
Now, if both ears had been affected by exactly the same frequency shift, I wouldn't have noticed anything wrong. It probably wouldn't have affected my ability to play an instrument in tune with others either, because all auditory stimulus would have been pitch-shifted.
I don't think this particular effect and condition (Diplacusis) explains your specific example of unexpectedly playing out of tune, but I hope it provides a useful illustration of just how delicate, complex, and ultimately fallible, our hearing and pitch perception can be!