Both machines and free weights can be part of a good resistance training routine. As long as you’re using a weight sufficient to stimulate your muscles to grow, either one will do the job.
Beginners should start out with machines. As long as you have the seat height adjusted properly, its very hard to injure yourself. Since a machine is fixed (you can only move in one direction) it will isolate a muscle better than free weights will.
With free weights, the dumbbell or barbell can move in more than one way. It can move in the direction you want it to (up and down) but can also move from side to side. Because of this movement, you have to use more muscles to balance or stabilize yourself than you would with a machine. This gives you a better total body workout but won’t isolate as good as a machine.
The best routine will use some machines and some free weights for each muscle group. They both have their strengths and weaknesses so combining the two will give you the best of both worlds.