What you are experiencing is part of growing up. You are becoming aware of the nature of mortality. You are becoming aware of the cosmos-at-large and where you fit in. It can be a humbling and terrifying experience, so your response is entirely understandable.
I am more interested by your account of the physical sensation you experience, the episodes you recounted. That sounded like de-realization or de-personalization. I have practiced meditation for many years, so I can generate the effects of depersonalization at my whim, but your sudden onset must surely be upsetting.
Once an individual presents the potential for deperson/derealization, they will experience it at times all throughout their lives, there is no cure; it is not a disease, it is an alternate interpretation of your perceptions. It is detaching from the self and suddenly observing all of one's sensations at once. For some people, it is a method of reassuring themselves that they are still alive!
Commonly, when a person experiences deperson/derealization, it is accompanied by a strange tingling or even a numbness, and the person has to "rub the feeling back in", the episode can last moments or persist for up to a day. There are many triggers for deperson/derealization, for some such as myself, we can generate if with a little bit of concentration, for others it comes on all of a sudden, such as when thinking of things on a larger scale than themselves. For some, it can be triggered by heights, of even a change in air pressure.
It could potentially be neurological; a form of misfiring of neurons in the brain, or it could be psychological; the person "switches gears" perceptually, albeit unwillingly. Science has not made much progress on the subject, I am afraid. The only treatment is therapy, learning to console yourself and establish methods of self-actualization.
I actually enjoy the sensation, I examine myself minutely when an episode occurs, seeing just how far I can "pull back" my perception from my body. But not to imply that you should feel the same way.
Since we share this experience, you are welcome to message me any time. I will provide whatever insight I may have.
Don't worry, life feels short all of a sudden because life IS short. Do not view that as terrifying, there is nothing more natural. All things that have ever lived have died, all things that ever will be will also one day end. Life is finite and fragile, but therein lies its beauty. Life is precious because it will end. Therefore, treasure and protect your precious life; it is the only one you will ever have, so it would be the act of a complete fool to waste it, no?
Always remember: the meaning of life is to give your life meaning. Nobody can do this for you. Never let anyone or anything stifle your will to live happily, you deserve the same chance at pursuing your happiness as anyone else. Most importantly, never forget that you matter, and you are not alone.