I'm so sorry for your losses. I've had small animals (currently guinea pigs and hamsters) for a long time. Most of my life, really. In the past year, we've lost four pets, Hadley (the pig in my avatar picture) who was my good buddy for 6.5 years, plus three hamsters (two of old age, one who really was not that old and who we tried to nurse through a medical emergency only to have to have her put to sleep several days in when she abruptly took a serious turn for the worse.) It is HARD. Really, really hard. And I absolutely have moments where I feel like I just can't keep doing this, especially with the really little hammies who really only live a couple of years. You don't love them less than bigger pets, but you have them such a short time and it's so difficult.
I think what really helps me is to reframe things a bit philosophically. I go in realizing that, barring something catastrophic happening to me, I will outlive them. They are on loan to me and I have no idea how long that loan will be. They are passing guests, and all I can do is be the best possible host and give them as many good todays as possible. They aren't concerned with lifespan, or mortality. They just want to be content right now, so I try to do the same. For those who die of old age, I try to remind myself that dying of old age after a happy life is the win state of existence. They crossed that finish line after a wonderful life and it's a privilege and a victory to have helped them do so. For the ones I've lost earlier to illness, it's harder to process, but at the same time I know I did the best I could and they had no sense of an allotted lifespan... what matters is that they were happy while they were here. Animals don't know how to count the days, it's always 'now.' Counting the days is purely a human thing. As long as their days were mainly happy, I did my job. And so did you.
Ultimately I keep getting small pets because I've always been drawn to them. The only way to avoid losing them is to never have them, and honestly that would be a bigger loss because the joy I get from them while they're here is worth the pain I feel having to say goodbye. I think everyone kind of has to weigh that for themselves. But for me, I keep weighing it and landing on the side of saying yes to pets, because having them and losing them is still better to me than not having them at all.