I think it wasn't like building in the middle of the ocean, it was on dryish land in a marshy lagoon. Probably the earliest houses just sat on the ground, but bigger and heavier ones built later as people became richer would have needed longer and stronger piles to support them. Venice came to be a very wealthy city, in control of major trade routes between east and west, so there was plenty of money around for this type of thing. It wouldn't all have been built at once, but over several centuries. A big job all right but not an impossible one for a rich city.