If you are more dense ('heavier') than water you sink. If you are less dense ('lighter') you float.
If you want to be about the same density as water for example, as most fish or submarines do - then you have to be able to change your density. You do this by letting water in to special chambers or pumping air into them. When filled with water you sink, when you fill the chamber with air, you rise. Somewhere in between you can just stay motionless in the water.