Lydia goes to jail
Solution 1:
Looking at this thread, I think one of these is a likely cause for Lydia:
You may have given her a stolen item or had her pick one up. I believe the non criminal AI is programmed to surrender (Brand Shei for example) so that may be the case. I've gone miles outside of Whiterun, stole something, and then had the guards bugging me. If Lydia "stole" something in the hold, the guards may have arrested her.
Another possibility:
Happens to me with Lydia and Jordis. I think I was "trespassing" in the Jarl's quarters and I forget that they have pathetic sneak skill + wear heavy armor
Personally, I am thinking it is the second. I found another thread that mentioned something similar:
IIRC followers can sometimes get arrested for trespassing. I forget exactly how you go about making this happen but I believe it involves fast travel.