It seems increasingly likely that there was originally quite a bit of liquid water on Mars during the Noachian (https://en.wikipedia.org/wiki/Noachian) and Hesperian (https://en.wikipedia.org/wiki/Hesperian) -- the Martian geological time periods more or less contemporaneous with what we call the Archean Eon on Earth. It's not clear that this would have been quite as extensive as "oceans" yet, but it's definitely possible.
As to why the water was lost, it basically all boils down to "Mars is too small". Too small to have a strong gravitational field that makes escape velocity hard for gas molecules to achieve, too small to have enough primordial+radiogenic heat driving a magnetic field to protect from solar wind, and too small to have primordial+radiogenic heat to drive plate tectonics and the silicate weathering feedback (https://doi.org/10.1029/JC086iC10p09776) that stabilizes liquid water on Earth on billion year timescales
As for how: ions and molecules reaching escape velocity. For water in particular, a lot of this would have been through hydrogen escape, which actually happens on Earth too (just slower). If you photolyze H2O, it's very easy to lose the H because it's so light, thermally or by solar wind, etc. There's more info on the how here: https://en.wikipedia.org/wiki/Atmospheric_escape
That's why those schemes for terraforming Mars seem so unrealistic. In order to sustain an atmosphere over the long term we'd have to keep dropping ice comets down the gravity well. There's no way to make it self sustaining.
oh, forgot about this paper (https://www.nature.com/articles/nature05873) which makes a pretty reasonable argument for paleo-shorelines on the northern basin of the Martian dichotomy. If this is correct then it'd be entirely reasonable to call the body of water responsible an "ocean"
As to why the water was lost, it basically all boils down to "Mars is too small". Too small to have a strong gravitational field that makes escape velocity hard for gas molecules to achieve, too small to have enough primordial+radiogenic heat driving a magnetic field to protect from solar wind, and too small to have primordial+radiogenic heat to drive plate tectonics and the silicate weathering feedback (https://doi.org/10.1029/JC086iC10p09776) that stabilizes liquid water on Earth on billion year timescales
As for how: ions and molecules reaching escape velocity. For water in particular, a lot of this would have been through hydrogen escape, which actually happens on Earth too (just slower). If you photolyze H2O, it's very easy to lose the H because it's so light, thermally or by solar wind, etc. There's more info on the how here: https://en.wikipedia.org/wiki/Atmospheric_escape