There are certain areas in Kingdom Hearts 3 where you can swim in the water, and even dive underwater. You won't really need to swim at all until you reach the Pirates of the Caribbean world, and at this place you will definitely need to both swim and dive a lot.
To swim, simply go in the water. Luckily your character won't just sink to the bottom, and you will instead swim. Control just like you would on ground.
You can also easily dive in Kingdom Hearts 3 by pressing L2/LT (depending on console) when you are in water. Hold this button down to swim further down, and press R2/RT to ascend when you feel like going up to the surface again.
When you are underwater, the Circle/B button will make Sora swim faster, which is nice when you plan on swimming more than just a few meters. When holding down this button, use the Up and Down button on the D-Pad to ascend or descend fast.
You do not have to worry about an oxygen meter or anything like that in Kingdom Hearts 3, and you can stay underwater for as long as you want to. You can even fight underwater, and you will have kind of different attacks when attacking underwater. There are some restrictions to which magic spells you can use while underwater, so try out your favorites to find out.