Why doesn't my Eevee rendered image match my view through the camera? I have a single icosphere in my Blender project and I'm using 2.91.0.  My active camera has a background image of a few buildings and I have a foreground framing image that's a blue box that fits around the edges of the rendered area and the rest of it is alpha channel, so it can be transparent.  The icosphere has a brick texture.  This is all just for testing.
Here's the Blender window.  I've hit numpad-0 so the view is through my camera:

Note that I have two images specified in the Camera editor on the right, one for foreground, one for background.  I've also changed the offset for the background image and, in the Lens section (at the top of that editor - the top part of that section can't be seen), I've set an offset to put the sphere on the point of a small tower on a building.
In the 3D view, you can see the light blue frame I created (that's in the foreground image).  The rest of the foreground image is transparent.  You can see a bit of the orange camera image outline underneath the blue outline.  So the blue should be framing the image when I render it.
Here is the rendered image, using Eevee:

There are a number of differences:

The frame in the foreground image is missing.  (Note Opacity is set to 1.0, so it should be there.)
The rendered image includes the entire background picture, not just the area framed by the camera (which matches the area I have framed in blue).  The foreground image is the same size, in pixels, as the specified image size for rendering (set in the Output Properties editor).
The sphere has moved to the left and up from the position I set it in when looking through the camera view in the 3D Viewport.

To render, I just went to the menu and picked Render-&gt;Render.  (I use an iMac which uses the function keys, so I don't use them for individual programs.)
Why are there these significant discrepancies between the rendered image and the camera view in the 3D Viewport?
Blend file from blend-exchange:
First have a look at camera background images in the documentation:

Crop
Scales the image up so that it fills the entire camera view, 
but without altering the aspect ratio (some of the image will be cropped).


The image is scaled at minimum so that either its height or its width fits the view.
Then you have shifted the background image of -0.104 along Y.
Now in the compositor, you've used a scale with crop option: that means the image is cropped then displaced (if you displace it) so you'll have a transparent part at the top. This is probably not what you want to do.
You can use a &quot;transform&quot; node instead, and some little math.
Your image is 4032 x 3024.
The render setting is 1350 x 800.
As crop from camera background image has adjusted the width. That means you have a scale ratio of 1350 / 4032 = 0.334821.
That give a height of 3024 * 1350 / 4032 = 3024 * 0.334821 = 1012.5.
As you've moved the background image of -0.104 (which is -10.4% in the camera coordinates), you have to shift the image in the compositor of -0.104 *1012.5 = -105.3
That gives this compositor setting:

To add the blue frame which has the same size as the rendering, you can add another alpha over setting on top of the previous one:

And if you want to avoid the above math/calculation, you can also parent to the camera a plane that will render the background.
Place the plane far from it, then scale and move it as you need. The plane has no shader to render with its full colors (don't forget to adjust the camera clipping if the plane is too far):

A blend file for this last setting: