In the gym there are often many different ways to do the exact same movement just using different pieces of equipment. Resistance machines work in a fixed movement plane, so for beginners this is beneficial, as it means there is little risk of poor form and injury as a result. It also allows you to train with heavy weight without the danger of dropping free weights, so no need for a spotter.
On the other hand, people will usually progress their training programme to using free weights. As long as you are using the correct form & technique and choosing an appropriate weight for your strength and ability, using free weights does have other benefits. You are using more core/stability muscles when using free weights as you are not in a fixed position, therefore your core muscles will engage to keep your body still, you may not realise this, as mostly you will do this subconsciously. So when using free weights, you are engaging more muscles overall, burning more calories and forcing a higher metabolic rate during an exercise in comparison to doing the same exercise on a machine. Also, free weight exercises are more functional, meaning more similar to movements you may need in everyday life. For example, picking something heavy off the floor; using the leg press will mirror the movement made and match the work done with your legs. However, if instead you did a barbell deadlift; this matches where you are lifting the weight from as well as matching the work of the legs. It also matches the core muscles worked, especially the lower back and you are using your arms as well, where on the leg press you aren’t using your arms at all.
So if you are confident and have a bit of knowledge in the gym, I recommend using free weight exercises for a more whole body workout.