Hi Sarah,
Stuti is right. You have to prepare since 3 month earlier than planning for a marathon. Also, if you really think that you have made mistakes in previous marathon, then try to recall it and see where you went wrong. Prepare for your overall body and not just your lower body and legs. Workout for your body including the running in a day and try covering more distance in less time. For example, if you are running 3 km in half an hour then try reducing the timings by 2 minutes and try covering 3 km in 28 min and so on... Always do stretching in beginning and ending of your any workout and marathon. Have water in between of your marathon so as to run for longer duration. As dehydrated body can break down early then a hydrated body.
CHEERS !!