I think there is a way of flashing a Samsung without erasing data, but I don't know the details. But you will need to be able to get it to boot into the appropriate state (download mode I believe) before you can flash it: if it won't power up at all there is nothing you can do apart from see whether someone can repair it (without erasing it or replacing the motherboard, since either of those will lose your data).
It's very hard to say what the cause here might be. If the reason you replaced this phone was the battery not holding charge then the battery failing is one possibility. Perhaps try leaving it on charge for a while and see whether it comes to life? Phones only run from the battery, and the charger connection only charges the battery, it doesn't power the phone, so if the battery isn't capable of charging you won't be able to boot it.
As an aside, if it's possible that the battery may be that bad keep an eye on it while charging. I replaced a Pixel 2 in December because the battery had become unreliable, but there was something on it I wanted to access today. I put it on charge last night and after a couple of minutes there was a "pop" and the display partially separated from the phone! What had happened was that the battery has swollen and pushed the display out (there had been no hint it was that bad before this happened). It's dangerous to try to charge a battery in that state (fire risk), which is why I say that if it's possible that the battery has failed completely then it's worth a go charging it for a few hours but don't leave it unattended, just in case.
Of course there can be other reasons why the phone won't power up. One other thing to check is whether it actually will boot up but the screen is dead: can you get it to make a sound, or can you see it connect to your WiFi network? That may be a long shot, but if that were the case there may be other things you can try.