Good buoyancy control is one of the fundamental skills you learn in your open water course but as with driving a car; you only start to learn how to control yourself after you've passed your test. There are many key factors that affect your buoyancy underwater but you need to start with your weight belt as this will have the largest effect on your buoyancy.
The first key factor in buoyancy is the amount of lead you take with you, it has a constant downward force that will not change throughout the dive. It doesn't compress like neoprene so it will be a constant negative on your overall buoyancy. The key to good buoyancy control is to carry as little lead as possible. As an Instructor I always wanted my students to have too much weight, than not enough, so when you start to dive you'll most likely be over weighted on every dive. Now there's two reasons for this; when you first start diving you still have an in built reaction to take deep breaths underwater so you take in big lungful's of air which make you float, also a runaway ascent is harder to prevent or fix for an Instructor or student than a fast descent. Students will often keep this figure in their head of the amount of lead they need and continue to use that much lead as 'my Instructor told me that was how much I need'.
As you relax into diving you need to constantly reassess how much lead you need for each dive, every time you change a piece of equipment, every time you dive somewhere new you just need to do a good buoyancy check. This you learn in your Open Water course but it is often overlooked or done wrong as most people still use way too much lead. Too much lead means you need to compensate its effects at depth by adding more air to your BCD which makes for a greater change when ascending, so you're constantly adjusting the amount of air in your BCD all the time. You want to be using as little air in your BCD as possible.
As a general rule of thumb; you need 2kg of lead to offset your tidal lung volume, so if you're diving with an aluminium cylinder and equipment that is neutrally buoyant with no wetsuit 2kg of lead is a good place to start and add more if needed. Adding a wetsuit or a drysuit will require more lead as these are typically positively buoyant. At the beginning of each dive do a proper buoyancy check, take your time and empty all of the air out of your BCD, every last bubble and breathing from your regulator you should gently sink when you exhale. If you plummet down under the waves you have too much lead, if your head stays dry you will have trouble staying down at the end of the dive.
Trim is the term we use to describe how your weights are distributed over a diver to give a proper horizontal position whilst diving. You want to be as horizontal as possible whilst diving, which can feel a lot more face down then you are used to. If your fins are lower than your body you will constantly be swimming upwards, thinking you need to adjust your BCD often, wasting air.
Your centre of gravity should be somewhere around your ribcage, to test this when you're neutrally buoyant just go completely limp and see how your body position changes. If your legs begin to drop then you need to take some weight off your waist and move it higher into trim pockets on your back or on your cylinder cam band. If your legs float up you need to move your weights further down your body, maybe to the point of ankle weights.
Trim can also be helped with the type of BCD you have, air in BCDs will always migrate to the highest point. Jacket style BCDs allow the air to migrate all around you and can make it harder to control your position if the air migrates around to one side. Wing style BCDs are typically doughnut shaped and keep the air dorsally on your back giving you a nice horizontal position in the water.
Watch your Instructor or dive guide as they ascend and you'll realise how little they adjust the volume in their BCD because they only have as much lead as necessary. When you're perfectly weighted you don't need to add air to your BCD, any air in your BCD is susceptible to volume changes as you ascend and descend. Even a small amount of air at 30m will be four times bigger at the surface, this is what leads to runaway ascents as this volume will increase exponentially as you ascend.
The real key is practice and time underwater; the more time you can clock underwater the better. Dive clubs are great for this as you can clock up some hours in a pool with your equipment and move your weights around to experiment. There are often experienced divers and professionals to help, play some buoyancy games and try to use as little lead as possible.