Prevent Lydia from 'protecting' the enemy from your arrows
Solution 1:
The mod, SkyTweak could help. Try tweaking the ff.variables in the 'NPC' section: 'Follower Spacing' and 'Follower Catch Up'. This should make your followers keep their distance from you.
Follower Spacing: How closely a follower will try to follow you.
Follower Catch Up: Speed bonus provided to followers when they are far away from the player character.
The tweaks won't stop the follower from entering a fight, but will make them increase their distance from you. This makes them less likely to get in the way between you and an enemy you're fighting. AFAIK, there is no way to completely tweak a follower's behavior / AI to make them get out of your line of sight when you're fighting an enemy.