There was no existing country, it was British territory, and Ottoman, and others. The last time the place was an independent country it was part of the ancient Kingdom of Israel, around 2,200 years ago. And now it's an independent Israel again.
Same place, same people, same name, same capital. Different laws and government though.
Everyone who was living in the area that considered the land their homeland were welcome to stay, maintain their private property, and join the fledgling nation. Arabs who stayed and abided by the UN agreement were given first-class citizenship and many went on to become leaders, run successful businesses, and even serve as officers in the IDF. Unfortunately, many rejected the UN agreement and even rejected the terms for a second Palestinian state for the alternative of trusting the call of neighboring nations to flee and fight. Unfortunately those neighboring nations ended up reneging on their word after losing the wars that they started and were not so welcoming towards those who fled, setting the stage for the current quagmire.
To be fair, the people alive now were not in a decision-making position back during the formation of Israel, but I wanted to bring up the historical context since we're discussing the formation period.