At the risk of oversimplifying, and with an explicit warning that reading words is no substitute for working with a proper trainer who can plan a good programme, watch your movement live and correct mistakes immediately, and generally help you train safely and effectively...

Planning a good programme mostly isn't about specific exercises, except for avoiding a few that persist in popularity even though they're actually really bad for you. It's more about balancing so you don't focus too much on one area relative to another, and then you also need to use good form when you move so you really are recruiting the muscles you intend to without damaging anything else. If you don't balance your training well, or you train with bad form that has the same end result, a couple of things are likely to go wrong.

The first is if you have opposing muscle groups but train one side much more than the other, either through neglecting exercises on one side or through bad form so you're not getting the full benefit of the exercises you are doing. Barring injury, you'll still strengthen the muscles all right. However, you'll then find that instead of the muscles having a comfortable neutral position and supporting any nearby joints as they should, you permanently have the much stronger side pulling on everything. This makes you vulnerable to all kinds of injuries and complications. It also means that in the real world, your strength will be less useful in practice than it could be. (It's also potentially an underlying cause of bad posture, which I think is where we came in.)

There's no big secret to avoiding this. Just be careful to train both sides of an action reasonably evenly. If you're doing bench press to build up your chest, do some rows to build up your back as well. Shoulder press? Do some pull downs or chin-ups as well. Hitting your triceps? Don't forget your biceps. Be particularly careful with the legs, because so many exercises naturally use a pushing action, but big quads and weak hamstrings does not make for happy knees and hips.

A second very common mistake is to focus mostly or entirely on the bigger, stronger muscle groups. They look great all pumped up, and they do provide the majority of your practical strength. However, your body is also full of little muscles that co-ordinate and stabilise everything else, so you can deploy the strength of your major muscle groups efficiently and safely. If you don't train your supporting muscles to back up the big guns, then sooner or later all the extra power in your big guns is going to get put somewhere that can't handle it, again probably resulting in sprains, strains, or worse.

The best general advice I can offer to avoid this one is to try to focus on compound exercises and free weights for the most part. (A compound exercise just means one that uses multiple joints and muscles together at once. Almost any "big movement" exercise you see at the gym that isn't done with a machine partially controlling the weight/resistance is going to be a compound exercise.) If you use machines to isolate specific major muscle groups, you can really concentrate on building those up, but the machine is probably also lending support to the surrounding joints in a way that natural movement won't. Do that for most or all of your work-out and neglect other kinds of exercises and you'll build up the big muscles but neglect the stabilisers, and the first time you realise it may unfortunately be when you try to move something substantial in real life away from the gym and find you didn't have nearly as much functional strength as that nice increasing weight on the machine made you think you did.

I hope that helps with your question, but again I really can't stress enough how important it is to work with a good trainer, at least to start with, if you want to get into gym work. They're not just there for encouragement or to spot you on a heavy lift, they're also there to help you make the most of your work-out and get better results sooner just through training with a good combination of exercises and good performance when you do them. Finding the right trainer was one of the best life decisions I ever made.