If it were as simple as lift some weights and do some cardio then everyone in the gym would look like Arnold Schwarzenegger or JessEnnis-Hill. Sadly, in most gyms 99.9% of people do not look anything like the superstars of sport and fitness and that is mostly down to poor technique.
Simply, if you do not perform the exercise correctly you will not get the correct results and risk injury. Key to this is the need to be in control of the weight at all times, so that means you can only use momentum to help in Olympic/dynamic lifts (rarely seen outside specialist gyms). The positioning of hips, knees, feet, the back, elbows, palms and so on all play an important part in determining whether you are targeting the correct muscle(s) or not. In this video Pro-Bodybuilder Ben Pakulski shows how the little differences affect tricep isolation:
In general it is best to work each exercise through the entire range of motion in order to work each muscle(s) fully. Half squatting, for example, is likely to make you quad dominant and ignore the glutes (bum) and hamstrings muscles. Another is rounding your back during any exercise as this is a fast way to injury, and will decrease the performance of the upper back muscles for upper back exercises (Rows, lat pulls).
This is an area where knowledge of human anatomy becomes really useful as once you understand how a muscle, or movement works you will understand the little, but vital differences, to technique that matters. Taking a bit of time to learn how some of the main muscles work will pay dividends in improved training performance and therefore results and simple apps can be purchased for a couple of pounds if you have a smart phone or tablet.
However, if you can maintain perfect form throughout every set and rep, you are not lifting enough weight. It should take effort to maintain form for all, but the last 2-3 reps of each set as by then your muscles will be fatigued. If you have to use poor form more than that (ie all but first 2-3 reps), then the solution is simple, reduce the weight you are lifting.