I can't speak for all professors everywhere, but I am willing to bet that the following is a universal truth -- a professor's first graduated PhD student remains very special forever. My first graduated PhD student is now happily employed by a national lab. She married a classmate from graduate school (from another research group); her husband is from here, so every year when they come back to visit her in-laws, I get to see her and catch up. It is always a great pleasure.
I met her in my first semester on the tenure track; I was a typical overzealous, overly-demanding newbie teacher who wanted to cover too much material; many students were struggling. She had no background in my area and was taking the course to satisfy a breadth requirement , yet she was catching on extremely quickly, and by the end of the course left everyone in the dust pretty spectacularly. I was quite impressed, and would have loved to have her join my group, but she had already been working with another group for three years.
The semester ended, a few months passed, and she found me to ask if she could switch to my group, because she was unhappy where she was. I can't remember the details why, I think the project was ill-defined or otherwise unappealing. I was thrilled to have her join my group, but at the same time I was absolutely terrified -- I am untenured, what if her advisor decides to somehow retaliate? I was really scared at the thought of running into him (the former advisor) in the hallways, I talked to my chair and my faculty mentors to make sure they knew I hadn't poached her, that she came to me on her own. I never talked to her former advisor, partly because I had never met him (he's an affiliate of the department), and partly because I was clueless about proper etiquette and very scared.
She was the first student who switched to my group. By the end of the year, I had three more who switched -- one came from my alma mater with an MS, two worked with other advisors in my department but wanted to switch. By then I knew better; each time a student wanted to switch to my group, if I thought that was be a good idea I would tell the student to go talk to the soon-to-be-former advisor first, and that I was going to follow up with the advisor in person to make sure everyone is on board and happy...
Over the years, I have had several students switch to my group. The vast majority of them worked out really well and the switch was a good idea for everyone involved. In several cases, the former advisor actually encouraged the switch because it was clear that the skills and inclinations of the student were simply not a good fit for that group, but the student was generally smart and motivated. In one case, the former advisor encouraged the switch because the student wanted to be a professor in his home country, and doing theory is much less costly and much more likely to be sustainable in said country than relying on expensive equipment.
I have also lost students to other groups; one wanted to upgrade schools, two left with an MS and joined another group in which the style of work and the topics addressed were considerably different. I remember being furious when I had to let the first student go after two years of paying him as an RA; there was no doubt in my mind that he could not stay in my group, but I lamented all the money spent (of which I didn't have much at that point).
But, after some experience, it becomes clear that students switching groups is simply a fact of life. Actually, a student switching groups once is a fairly common occurrence in the physical science fields, because there are no rotations that the students can use to test the waters in different groups like they do in the biomedical sciences. As a professor, I have learned that you win some, you lose some: as long as you are not exclusively hemorrhaging students or actively poaching other people's students (I have never seen this happen, but it would be beyond douchey), I think it all comes out a wash. My initial lamenting over money spent was misguided -- sometimes you lose a student you paid, sometimes you gain a student someone else paid.
To the scared students who are unhappy, but terrified about switching groups: in my experience, professors don't generally think it's a sign of your deficiency if you want to switch groups. If your former advisor is a sane and decent person, s/he will let the new advisor know about your strengths and weaknesses, about how you got along, and why things didn't work out. So if you, as a graduate student, are unhappy, and have really tried to make it work in your current group but it just isn't happening, it is OK to consider switching groups. Just think really hard about where you want to land, because you really don't want to switch the second time if you can help it...
A new student started with me this week. He'd been working with a group in a department I am affiliated with, but, after three years and change, things were just not happening. I have known the student through coursework and have been quite impressed with him, so I am happy to have him join my team. His former advisor gave the switch a wholehearted blessing. I have a great project lined up for the student; he seems energized and excited about it. Things are looking pretty good.