I'm pretty sure that UPS has the batteries set up for 48 volts DC. So all four batteries are in series.
It is highly likely that the two batteries left over from the original batch, that you thought were good since the voltage was okay, are actually very much dead.
but they happen to be just barely good enough that they will float at the correct voltage, and everything looks okay until you put a load on it.
whenever you have a battery bank setup of multiple batteries in series, it is best to replace all of them at the same time so they are the same age and same capacity.
Sent from my Pixel 2 XL using Tapatalk