Some amateur golfers may have lateral movement in their swings. This can also be referred to as a sway. This is something that I consider an extra or unnecessary movement that doesn't really do any good for your swing. A golfer who moves laterally in their backswing, has to counterbalance it by moving laterally in the other direction on the downswing. This can be difficult to time correctly and compensate for.
This is a pretty simple problem to fix but it might take a little bit of practice. The way to fix a lateral movement is to stay in your posture on your backswing. Golfers who move laterally are not staying in their posture and in their angles correctly.
A great tip is to make sure at the top of your backswing that your right knee is still flexed the same amount that it was in the setup position. Your hip angle should also be the same. This will help to prevent any lateral movement that could happen in the backswing.
It's also important that at the top of your backswing, your weight is mostly in the inside part of your back or right foot. This means that your weight has shifted the correct amount. If your weight is rolling over into the outside part of the right foot, that means you likely had some sway in your backswing.
Remember that when you are shifting your weight in the swing, you are also turning. The weight shift does not happen independently from the body turn. Someone who moves laterally or sways is usually separating that motion from their body turn. Make sure that your weight shifts only as your are turning. This helps to prevent extra shift or lateral movement in the backswing.
If you've made a good backswing with a correct turn, then the downswing is simple. Just remember to stay in your posture until your club has swung through impact and is about halfway into your follow through. It's common for amateur golfers to stand up early in their downswing or at impact but this causes a lot of problems and can lead to lateral movement also.
As with any swing error, there is usually a fundamental(s) in the swing that is off. In this case, not staying in your posture or angles as the club swings is what goes along with incorrect lateral movement or swaying. The more solid your fundamentals are, the less likely you will be able to have bad habits or swing faults, and as a result, your golf swing will be more consistent.