This question is extremely vague. All I can say is, sometimes there is nothing you can do. Things happen, good and bad and you should always try to do what you can do but sometimes, you just need to take what happened as just another piece of experience that you can add to your portfolio and learn from it.
In life, there are things that we just can't do. We aren't all knowing and all powerful. It's important that we accept that life is what it is, and sometimes there's nothing we can do about it or to change it.
Many things are out of our control. As humans, we often want to feel as though we have control over things that we know deep down don't. Control gives us a sense of security, hence why you may feel safe driving behind the wheel of a car but not as safe on a roller coaster. When it's out of your hands, your safety net is taken away and you feel vulnerable. There are many things in life where it's a roller coaster for us and no matter what happens, we can't get off nor are we in control of the loops and sharp turns. Remind yourself that it's okay and not your fault if you couldn't have done anything, no one is blaming you for something out of your hands.
It all depends on the situation that you are speaking of. If you feel that you should have done something in a specific situation, perhaps talking with someone who you trust can help you to sort out your feelings.
Unfortunately sometimes there is really nothing much we can do... sometimes our body reacts by itself, sometimes the situation variables are such that they influence what we can do significantly... we cannot change what happened in the past, but maybe we can change what is happening from that point onwards
Oh ... life is like that, as the saying goes. I'm trying to imagine all of the situations that could lead you to ask this question. Is it great grief? Or regret? It's okay for you to feel all of your feelings. It's normal. You will go on, and you will find some of the answers you seek. As to the ultimate answers, there may be none for you. Some might say God willed this or that, others might say God gave them an opportunity to grow as a person. For some, it's simply "the universe" or "fate." Whatever you call your higher power, it can help you find the answers. If you don't believe in a higher power, that's okay, believe in yourself and your own ability to heal, and change and grow. Don't let grief stop you in place. Keep going on. I hope you can find the big answers. Until then, just keep going. Everything changes.