Foot IK weird

I was making a foot ik and the bones bend on the wrong axis

There is probably much more to it, but it looks like whatever you are using is twisting the knee pole/effector or not setting it at all.
Or potentially twisting towards 0,0,0

I suggest using modify bone to set the IK bone position, and the LegIK node to handle the IK.