So sorry to hear about your situation, S.. I know it's really hard to lose a pet. Our dog died when my daughter was 2. She knew the dog was sick when we took the dog to the vet one day unexpectedly and ended up putting her down while there. My daughter was not with us. So, we just told her that the dog was so sick that her body just couldn't keep working, the vet couldn't help her anymore and she died very peacefully. We didn't tell her that she was euthanized as it didn't make any sense at age 2 to do that. It's trickier when you are planning this all in advance. Our vet had lots of resources for kids and adults to handle the loss of a pet, so I would check with yours. We used the book Dog Heaven and also another that I can't remember the name of, but it was at Barnes & Noble and was about how everything has a beginning, a middle and an end. It starts with plants and ends with humans and is a nice, poetic, circle of life kind of message.
Expect lots of questions! Even at 2 our daughter talked about it constantly and we had so many conversations about death, heaven, etc. It was challenging at times, but kind of amazing, too. I would start talking to them now about how sick your pet is and how sometimes it's just time for a pet to let go, and you feel that this time is coming for your pet. Maybe start having some special time together with your dog petting his/her head and thanking the dog for all the things they love about about him/her. You could take the lead, especially for the two year old. You could say things like, "Thanks for being such a great friend. Even when you get too tired to be with us any more, we will always keep you right here in our hearts." And, "I love how you wag your tail every time I come home. I will always remember that and it will make me smile when I do." You can start preparing them now so that when their pet is gone, they are not unprepared and don't feel they didn't get to say goodbye. This can be a nice thing for you as well. Best of luck to you S.. And again, so sorry for your loss.