All huge philosophical discussion aside, isn’t Karma merely the law of cause and effect? What we do comes back to us. My mother always told me (she was a great Mom, and still is) that what you do comes back to you tenfold. It most likely is not a direct, obvious corollary. I can’t give an example, because anything can beget anything.
Think of it as energy waves. You are angry, you think angry thoughts, those thoughts are energy radiating away from you and within you. Affecting your inner organs and body processes, as well as affecting anyone you may be directing your thoughts toward at the time. These energy waves also behave as a magnet, attracting more of the same to you, but in more abundance. So as long as you dwell in the negative, you attract even more of it to you, and it does affect things that happen to you and the way that people behave toward you. It doesn’t affect only people. All is energy, so it affects your whole environment.
The same is true for positive energy! Learn to control the negative within yourself so it does not radiate (because we will always encounter negative feelings and thoughts within ourselves) and focus on sending out positive energies and behaviors.
Yoga helps with this as it helps you to gain control of the mind and the emotions. It doesn’t magically make it better, you also have to do the inner work for inner growth, but yoga is a tool to help you obtain your objective.
But don’t think that because something “bad” happened to you that you must have done something to draw it to you, unless it causes a light bulb to turn on in your mind that makes you think of something specific that you may be doing to draw this to you. There’s no easy answer, but this is a way of being that I have found to be True for me, but life is so complex, that when something happens, there is no way of really knowing if we brought it on by being out of balance, or if it was part of our life and part of the experiences we came her to experience to help us grow. Remember also, Good and Bad are merely subjective opinions. Desireable and Undesireable are more accurate.
All we can really do is live our lives the best we can, and know that when something unhappy happens, it is all in our reaction or response to it that matters. We aren’t being punished. Life just Is. We have to deal with it as it comes.
So remember, whatever you do always comes back to you tenfold, so choose your actions wisely. And your thoughts. 
