After effects | How do I copy an image source from layer to another programatically?
It depends how you mean: 

Option 1:
If you put the image in Layer 1 inside a Comp, then any change to the image inside the Comp will change in both Layer 1 and Layer 2 (assuming you also put the Comp on Layer 2).

Option 2:
You could put a load of different images inside a comp, a different one on each frame.
Then in your master comp, place this comp, but assign Time Remap to the comp, to choose to hold on a specific frame.  Then when you want to change the held frame, just keyframe to the different time in your first comp.

Option 3: 
If you really mean to change the image programmatically, you could use something like Templater Rig, where you can set a load of different file paths to images, and then assign them to different comps programmatically.