Nothing wrong. But bad IK behaviour of the Rigify rig, and the Blender bones system in general. The Blender IK solution is a bit aged.
You can either try to fix this by FK animation. Which battles with the IK then. Or you add a so called pole object that lets the knee point into a specific direction. The setup for this pole bone/pole object is a bit hard to explain. And i haven’t rigged for ages, I made my last rig back in 2012. So i am bad at explaining this chapter at the moment. Too rusty.
Maybe this one helps you a bit. The interesting part starts at minute 9 …