Free weights stimulate more muscles than machines and are thus ideally suited to muscle building in the long run. However, at the end of the workout, when your muscles are exhausted and your form struggles, machines are better and will help you continue your training safely.
If you want to build lean muscle, both nutrition and physical activity are important. To get began, challenging your body through physical activity is crucial. Your progress will stop, however, without adequate dietary support.