Why should a P.I be motivated to write a strong LOR even if that means losing a undergraduate from his/her lab? Suppose, you are the head of a lab, and there is a particular undergraduate in your lab that you want them to continue working in your lab while doing their graduate studies in the university you are working.
You know that the student wants to go abroad for their graduate studies, but if they can't, they will stay where they are (in your lab).
And they ask you for a letter of recommendation for their graduate studies.

Why should you write a strong recommendation letter for them, even though you know that it will increase their chances of going to another university for their graduate studies?

Note that, I've read this question.
When I am evaluating a research group leader, one of the most important things I examine is where their former students work.  If their former undergraduates have moved to PhD programs at excellent universities, that makes the group leader look like an excellent mentor who teaches their students well.  This improves the group leader's reputation and helps them recruit new students.

A savvy letter writer also knows that a letter which literally says "This student has excellent achievements x, y and z." implicitly says "I am a good supervisor for helping the student achieve x, y, and z."