Yes, I had this problem all the time. The reason is (I think - correct me if I am wrong - I lurve being punished) when you bend an armature on the opposite side of the parent bone, it doesn’t know which way to bend, so mathematically, it thinks bending backwards is just as correct as bending forwards. What I discovered is in a foot IK setup, go into pose mode and rotate the “thigh” bone forward about 60 degrees. Because of your IK restraints, the bone won’t actually move, but you’ll notice the degree counter displaying the number of degrees at the bottom of the main screen (on the bar that sparates your viewing area with your button area) Now when you move your foot setup, your “knee” won’t buckle back. Try it and see.
Hope this helps (was I clear?)