Our distressing thoughts such as regrets, worries, anxieties, or sadness about our pet or thoughts on how they passed keep us awake as we are focused on the thoughts. Thoughts we also focus on are how badly and hopeless we feel. These thoughts are spontangeous. We are not "doing this to ourself". If you shared your bed or bedroom with your pet it can be especially heartbreaking to sleep without them too which only adds to the stress of trying to sleep.
The stress from the loss of a loved one can develop into anxiety, depression, or post-traumatic stress disorder (PTSD). Each one of these conditions negatively affects sleep because of the thoughts that keep us up and believe it or not, physical pain too.
If you think that you might have clinical anxiety, depression or PTSD-- talk to your doctor about a medical approach.
I have meds on hand because there are some nights where I can tell this is going to be a bumpy ride. I can just tell and as of late I don't even
fight it. I was fighting it for a long time to prove 'I can handle this'. But there is no shame in taking medication for it's intended use. It's a sign of wisdom, good judgement and self care.