Hey, Guys!
In women particularly, knee pain associated with squats and lunges is due to patellar maltracking. Patellar malalignemnt/maltracking can be the result of any one or a combination of several factors. Specific muscle group weakness, soft tissue tightness, foot abnormalities, and gait abnormalities are factors that can be corrected.
In many cases, instead of getting better with training, it gets worse. That is because, contrary to what most people have heard, squats and lunges are NOT the best exercise for a person who has weakness, soft tissue tightness/restrictions or both, which leads to patellofemoral pain--at least not the way they are usually performed.
While squats and lunges are excellent exercises, they put huge stresses on the patellofemoral joint when there's alignment problems. Yes, proper form can help, but it seldom will completely correct the problem. Stretching, strengthening by working in a pain free range of motion (if that's possible) with squats and lunges, and relative isolation exercises for the quads and hip abductors typically make a significant difference. Using ice after a workout helps, too.
I deal with this on a daily basis, both with my patients and with myself--it is an ongoing battle. But, with proper treatment, the pain and long term damage can be minimized.
Maribeth