What is this for? I don't see the use case.
I think adding a border is an attempt to preserve the essential parts of the images in those situations. It really should not be necessary, but alas modern/stupid problems require modern/stupid solutions.
I did a similar thing for generating a video from multiple screen captures - GitHub repo here: https://github.com/KaliedaRik/sc-screen-recorder