There is a song by the band Creed that is titled "My Own Prison". It starts off stating that "Court is in session. The verdict is in. No appeal on the docket today, just my own sin". It's a profound song because it hits to the heart of many of our problems in our lives. First, we WILL be judged for our thoughts and actions. Second, our sins are like the links in a chain-link fence. They build upon one other until we have surrounded ourselves in our own prison. God has given us the free will to make decisions that will either let us live free of guilt and sin or to make desicions that will imprison us. We can build our own prison, be we cannot let ourselves out. Only Jesus can free us from the prisons that we create for ourselves.
They say that your life is the sum of your choices. If you've made a lot of good choices, you'll have a good life. If you've made a lot of bad choices, your life will be more difficult. This is also true for the company you keep and what you expose yourself to. You become what you see the most and you are who you associate with. All of these are choices that we make with free will.
When I look at the best, most successful, most positive times in my life, it was when I was in a healthy environment and surrounded by good people. It can change in what seems like an instant. I've experience that more than once. A job change to a bad environement, with people that are not "good" for you, leads to more bad choices as you ultimately become part of your environment. Very quickly, you're life can change drastically and you find yourself in a very different place. It's happened to me more than once. You wake up not sure how you got there and more importantly, not knowing how to get back. There is a line in a Pink Floyd song, titled "The Trial" where the singer reflects: "There must have been a door there in the wall when I came in?" You can't dig yourself out of a hole.
The good news in that life is a journey, so we can change direction at any time. God divided the day with night to remind us that every day is a new day and a fresh start if we need it.
You can leave your prison anytime just by turning to Jesus and asking forgiveness. He will forgive you, but you must ask. The reason you must ask is simple. If you don't accept that you've sinned, or maybe make excuses for your sins, or blame someone else, you are not going to think you need forgiveness. The act of asking for forgiveness follows the internal acceptance of sin and the responsibility for it. So, admit it. Genuninely regret it. Hand your cross to Jesus. In return, He will show you the way out.
If you're in a bad place or have bad things happening to you, don't ask "Why is God doing this to me?". Instead, find a mirror and ask "why am I doing this to me?" and then turn to Jesus for help.