Why are the bird's knees the other way round?

If you see a bird sitting on the perch, you will notice that the toes grip the perch. The leg continues towards the rear of the bird, where it bends forwards at a right angle like the human knee. This initially looks as if the bird's knee is bending backwards, i.e. the other way round than the human knee.