Yes, great question.
It helps to understand this by looking at muscles as occurring in pairs of antagonists. As one muscle in the pair contracts, the other relaxes. An example of an antagonistic pair is the hamstrings and quadriceps; contracting the quads (to kick a football, for example) causes the hamstrings to relax. Contracting the hamstrings (to lift your foot up to your bum) causes the quads to relax.
When you are prone with one leg straight up and the other leg lengthened out on the ground, if you pull the raised leg toward you, you are mainly stretching the hamstring and calf muscles. If you do not engage the quads at all, the knee will bend and you will lose the stretch. If you tense the quads a lot and pull the foot toward you, you will feel a very strong hamstring stretch.
However, there is much more to a stretch or a pose than the anatomy. Underlying the stretch is how we apply effort. Percevial is right in that you don't want to clench your knee, but you do want to engage the quads. The key is understanding how much. One of the principles in yoga is understanding the balance between effort and release, and you can do this by always feeling the energy in your body, or if you can't feel it, imagining that there is energy coursing through you at all times. It connects you to your body in a subtle, sensitive way so you begin to feel the delicate ways in which you can affect each stretch with tiny shifts in your body.
When you return to this pose, use the anatomical cues as global reference points (lengthen the back of the leg and flex the toes to the shins), but always use your body's energetic feedback as your guide. How can you energize the leg in a way that lengthens it without creating unnecessary tension? How can you hold the pose while allowing the muscles that are being stretches to release, for example.