Your understanding isn't exactly in line with the history, at least from my Jewish-Israeli perspective. In general, It's a complicated question, over which literal wars have been fought.
I'll try to give a version of events as I understand them. This came out fairly long, sorry.
There were Jews living in Israel originally, who were displaced and moved to other countries about 2000 years ago. There was a Jewish presence in that land from then on, but it was relatively small, though Jews worldwide theoretically yearned to return to Israel.
Beginning in the 1800s and up to the founding of Israel, there was a large movement of Jews to return back to their original land, and Jews started migrating into Palestine. This was afaik completely legal - the land was first ruled by the Ottomans, then the British, and the Jews who moved there bought the land and developed it (it was not a very developed land before then). The British at some point promised the Jews that they would give them that land to build a country on, kind of - it was a vague promise. Then the British decided to hand the land over to the UN.
After the Holocaust, there was a lot of pressure for the Jews to get their own country. The UN came up with a plan to divide Israel up into two countries, one part for the Arabs (Palestinians) and one part for the Jews, with Jerusalem split. The Jews accepted this - the Palestinians rejected it. Then, various Arab countries launched a war on the newly-formed Israel, which had to defend itself.
Most of the Arab population fled from Israel - I think it was partly because leaders of the various Arab countries told them to flee the fighting and let them conquer Israel back, and partly because of fear and of actual Israeli actions against them. How much each part of this is part of the reason the Arabs fled is kind of contested, I believe.
Israel (somewhat surprisingly) managed to win the war, and ended up with most of the land that was promised to both sides, which it kept. The Arabs that had remained in Israel instead of fleeing became Israeli citizens. The Arabs that fled became refugees of various countries. This was the situation until about the 1960s.
In 1960, there was another war between the Arab countries and Israel (Israelis generally consider this a war against Israel, cause Israel realized it would be attacked imminently and struck first. I think this is disputed though.) As part of that war, Israel managed to capture territories from other countries, including what is today the land of Palestine (the Gaza strip and the West Bank.) This land had all those refugees still living on it from the war in 1948. This is today's Palestinian population.
Israel gave back part of the land it captured (The Sinai), as part of a peace agreement with Egypt. The Palestinian population continues to live on in the lands Israel captured. Since they were never granted citizenship in any country (not the original countries that owned the territories, and not Israel,) they are still refugees.
That is kind of where the situation is today.