The best evidence we have is that the Gungan people mostly lived above ground until the Naboo (humans) arrived several thousand years earlier, initially on colony ships, and then in greater numbers as the wealth of their plasma fields became known, until they had sufficient population to merit their own Senate seat.
Palpatine: ...847 years ago, Naboo joined the Republic...
Clone Wars: Crisis on Naboo
Over time the Gungans were forced to retreat underwater and discovered that there was sufficient space to maintain their culture as well as plentiful energy that could power their cities and with sufficient surplus to trade with da Naboo for offworld items.
SECRETS OF OTOH GUNGA
When the amphibious Gungans were forced to retreat underwater in a fierce struggle for territory thousands of years ago, they stumbled upon a secret that enabled them to live there permanently. In deep waters, they came across a strange lifeform known as locap that burrows into porous rock and siphons out plasma. The Gungans found that they were able to extract plasma from the plant using special harvesting bongos (Gungan submarines) equipped with a front-mounted siphon. This natural source of energy has many uses in Gungan life, including the creation of their unique bubble cities. Plasma-based technology allows powerful hydrostatic fields to be generated around basic frameworks, keeping water out but allowing individuals to pass through.
Inside the Worlds of Star Wars: Episode I