Both exercises have their own set of benefits, but which exercise is best depends on your goal.
If you are a beginner, then you should squat. Squats don’t require proper balance, which is the reason why they are easier to perform. You can start this exercise with just your body weight (no weights) and then move on to some weights like dumbbells or plates.
For bodybuilding, squats are preferable to lunges. The reason is that squats develop more strength and muscle mass. Golden Era legend Tom Platz built a career on his squats. Once he perfected his squat and started adding weight, his physique became one of the best of his time.
For athletes, it would seem that there is not a large enough tangible benefit from choosing one or another type of exercise. However, lunges can work on muscle imbalances from one side to the other. If your goal is to create symmetry, focus on lunges until this imbalance is corrected.
Increasing the lunge type can also be seen as an exercise to improve balance.
Using different variations of exercises in combination with different intensities is the key to athletic improvement.