Current macOS versions are weird. Often when I connect my iMac the two screens on my desk, the wallpaper on one screen is either gone or changed to a different one.
After many attempts have the external displays keep the same wallpapers, I gave up and wrote a script that sets the wallpaper on all my screens like this:
osascript -e 'tell application "System Events" to set picture of every desktop to ("/some/path/wallpaper.png" as POSIX file as alias)'
This is a simple call to osascript (Open Scripting Architecture) which evaluates the AppleScript provided by -e.
Who thought it would be that easy?