People fail for a variety of reasons and the obvious, though difficult, task you must undertake is taking a serious objective look at why you had problems. I told myself a variety of excuses but the truth is, for me, I hadn't done enough the first two years to prepare myself. This caused significant anxiety as it is one of the few things you can't just "fix."
I felt like I had memorized FA but still was missing a lot of questions so I really focused on question/test taking to improve. To study for my final, passing, attempt I used almost exclusively questions to study. I did all of kaplan Qbank and Qbook (which I found to have better explanations), Robbins qbook, webpath (google it), and Lange's qbook. I also took the first 2 NBME exams. I made notes of all missed questions or questions that I got right but didn't understand well then read the notes from each day that evening before I went to sleep.
I also tried to keep my anxiety down by stopping caffeine and etoh, re-started my exercise routine, and giving myself study rewards/breaks. I talked to a physician friend of mine who prescribed propranolol for me which I took a few times while taking all day mock-exams (to make sure I could tolerate it) then took one the test day. If you have anxiety, which is hard not too after you have failed, then I'd recommend you talk to someone to see if this is a viable option for you- it helped me tremendously.
After I learned I passed, I re-dedicated myself to school and worked hard 3rd year for each rotation. I bought all the top step 2 books the first day of 3rd year and read the corresponding sections for every rotation while studying for the shelf. The month before step 2 I again did thousands of questions, made notes on those I missed, and skimmed the review books.
Good luck!