Now this can happen for a variety of reasons, reasons that don't really matter for me to make a point. All you need to know is that it happens and it will happen to you too. Know too this is not a bad thing.
Whenever someone gives me their notice I tell them, on behalf of the agency, I am bummed. Unexpected replacement of staff is a more-than-slight pain. I also tell them, on behalf of me, that I am so excited for them. Taking the next step career step is such a good thing and I love when people make it happen. I call it putting another slice in the pie.
Every job you have is a slice of pie. Over the course of your career, you can have 4 big slices or 8 smaller ones. Just always remember that it's not the entire pie in each career decision or move you make. This takes some of the pressure off when you agonize if you've made the right decision to go somewhere else. It's just a slice moving further down the path of making you whole.
You will always be learning and growing with each place you go. Even if the place turns out to be not all that stellar. You learn from it and move on. In the end, you are building your career.
Go forth and make pie my friends.