|those juicy lips mmmm...|
There are a few reasons why you might lose Lydia
1. She dies
2. She gets left behind in a glitch where her character can't move
3. She runs off to fight a nearby enemy, (one time she rans straight into the water to fight off some kind of fish!) Luckily I used a previous auto-save to get her back.
Before a battle, save your game. You can save during combat as well. Many times I ended up beating all the enemies but accidentally hit her with my weapon or magic (she gets in the way) and she dies. Sometimes other characaters who are temporarily helping you will get in the way and accidnetally get caught in the line of fire (no friendly fire in this game) so it's always a good idea to save BEFORE battle and DURING battle!
Another reason why you might lose Lydia is if you accidentally tell her...
"It's Time for us to part ways"
This happened to me once, either through a glitch or accidentally when I was trading things with her. (don't forget to give her better armor and weapons!)
If you lose Lydia and just need someone to fight alongside you don't worry, you can pick up other characters (some which might be better than her). At the Inn in Riverwood (I think) there was a guy who for some gold would agree to fight with you. But he insists that you have to let go of Lydia first (they limit you to only one partner in crime). I think a good replacement for Lydia is J'Zargo. He is at the College of Winterhold. Once you get rid of Lydia (or lose her) when you talk to certain characters you will see an option that says something like "I need your help, follow me"
If you tell Lydia we need to part ways, she'll say "I'll head back home if you need me", she'll be in Dragonsreach sitting at the table, simply talk to her and she can follow you again. Once you purchase a home in Whiterun ($5,000) she will wait for you there (2nd floor). You can see my other post for how to purchase a home HERE