Unless you make Lydia your spouse and inform her of the move, she will always return to Breezehome (if you own it) or Dragonsreach (if not) when dismissed. It may be possible to change it using factions, but I seriously doubt it. I might try an experiment later to see if I can influence the default behavior.
the housecarl is an assigned military representative of the town where you are Thane... Lydia lives in Whiterun forever and will "follow" you anywhere, but will return back to Whiterun when you let her go home. Same of the housecarls of all of the other cities. "I will protect you and all that you own with my life. I am your sword and your shield."
She is a House Carl of Whiterun. She never moves from Whiterun because she has allegance to the Jarl there. She is assigned to you as only because you are a Thane of Whiterun.
So it makes sense that she stays in Whiterun.
As mentioned above, you can get House Carls in other cities.
Oh, okej, i tought that this, "I will protect you and all that you own with my life. I am your sword and your shield" was for whole skyrim, but well, it's not bad, she's alowed to protect my home in whiterun
I usually try to get another house as soon as I'm able. I can't stand the squeaking chair, because Lydia can't make up her stupid mind whether she wants to get up or sit down! ugh. Yea, she can stay in Whiterun for all I care! LOL