I've had similar. I'm not long back from a knee injury. When it got bad I had to drop all bilateral movements and all I could work on - on the advice of a physiotherapist - was single leg squats along with some stretches and some activation stuff. When I started back on Bilateral movements, first being deadlifts and pull throughs, my knee would always feel better. It would feel much more 'solid' / stable, if that makes sense.
Sometimes, when it aches a littel during the day or whenever, a workout of box squats, front squats and / or DL's would make it feel great. If it's ever sore, I can always make it pain free during my warm up.
I'm not sure the reason behind it. I do know that it's not really an accurate assessment of where you are with the pain. When I first seen my physio, he said "no squats or deadlifts". So, I found a loop hole and done rack pulls. Felt great, until the next day! Then I got told "no bilateral means NO BILATERAL!". ooops. Anyway. point there was that it felt great straight after the exercise, but the next day I paid for it. This is the case with most 'joint pain'. You generally don't find out if you've pushed too far until later that night or the next day.
My theory behind it is a couple of things. Increased blood flow to an injured or sore joint almost always makes it feel better. You'll get that from training, especailly squats. Also, if your squating properly, you're going to get your glutes working hard. Glute dysfunction is the most common cause of knee injury, by squatting, your 'switching on' these muscles. Since the hip stabilises the knee, this would take less stress off the knee and could get rid of the pain.
Similarly, if you have a tight ITband which causes pain in the knee, you can get rid of the pain by foam rolling the TFL, which pulls on the ITband when tight. Foam roll it, and stretch it, and quite often, the pain will go away. especilly if you top it off with some glute activation.