How to teach students not to use other people's work in an assignment or a thesis?
It seems to me that you have an "Academic Integrity" issue as opposed to a "Plagiarism" issue. Academic Integrity covers many areas including:


Plagiarism
Collusion
Fabrication


and so on...

In my personal experience the biggest 'excuse' that students will plead is ignorance. What this causes is the following cycle:


students submit work
work is marked
issues are found
issues are discussed with student
student pleads ignorance
student is educated
(sometimes) student is allowed to resubmit


The problem here is that education comes after the crime, and any resubmissions can drastically delay students receiving marks and feedback (which feeds into other assignments).

Now I do not have a solution that will stop all cases of academic dishonesty and personally I do not think it is possible. If people want to cheat, they will. The key is to remove the accidental plagiarisms so that the focus is on the intentional cases.

To remove the ignorance excuse the answer is simple: education. Now you are already employing education as your solution, however, you are doing it after the submission. The key is to do it as soon as possible. Personally, I use part of my first tutorial class to teach the students what Academic Integrity is, and then get the students to work through some examples and questions. Lastly, I require them to complete an "Academic Integrity Quiz" which is regulated by our University Library. Before the students can gain access to our assignment submission boxes they MUST have scored 10/10 on that quiz (this is automated). Unlimited attempts are allowed on the quiz as well.

The solution above forces students to learn about Academic Integrity and thereby removes the "I didn't know" (ignorance) excuse.

I hope this helps.