People float in water by having a lower density than the water surrounding them, according to Scientific American. Because human body fat is less dense than water, people with a higher proportion of body fat float more easily than people with low body fat. Taking a deep breath also decreases body density since air is less dense than water, as discussed by MechLabs.
The website Relax and Swim outlines several techniques to increase buoyancy in water, such as drawing in more air with each breath, relaxing the muscles, and focusing on the body's position in the water. Factors that affect a person's buoyancy in water include body composition and alignment, lung capacity and salt content of the water. People float more easily in salty water since the salt makes the water denser.
As explained on Wikipedia, Archimedes' principle, named for the Ancient Greek physicist who first discovered this law, explains that when an object is immersed either totally or partially in a liquid, the object is buoyed by a force that is the same as the weight of the liquid that the object displaces. This means that an object floats if the weight of the fluid it displaces is equal to or greater than the weight of the object.