when you render, the background you see is set up in the "environment" dialog, from the "render" menu
the viewport background is only a design-time helper
be sure you set up the correct background in the environment
you should also check the "show safe frame" in the camera's viewport menu, because this way you will see the area corresponding to your actual render size
i must say that the fact of the second background appearing in the distance sounds quite wierd.
did you check the camera's FOV? did you use camera matching for the job?
when you say that the animation is way off into the distance, it may be because of incorrect FOV, or because you have an extreme difference between the render dimensions ratio, and the viewport dimensions ratio. this second case is what would be resolved using the safe frame.
double check all those things and if you don't find the problem, report feedback and some more infos