So many of my friends have moved after a few years, how can I trust people again?

Easy. Understand that trust is a very fluid matter but that people come and go is the nature of our world. When they leave, they are going towards something , not going away from you.
Keep in touch. It almost sounds like you are feel somehow you are responsible for them moving away. I would be willing to bet they were no less disappointed at having to move away than you were at their moving. Hopefully you have tried to keep in touch with many of them and if they are indeed friends they would be happy to see you, either visiting them or they you. Make an effort to do so. Trust your friends.