Known as the "queen of exercises" the squat is a very natural movement pattern. There are many ways to perform it but for simplicity reasons I will predominantly talk about the back squat with or without a weighted bar.
Why is it so special?

Well, performing a squat is not so special at all - every child can do it. But that's the point. This movement pattern was with us since we developed our body. Many people lose this ability because of the convenience of chairs and other unnatural sitting accommodations.
You won't believe how many people can't even do a body weight squat.
Why you should do them:
1. When you don't do squats your hips and legs forget the movement and tendons shorten. The lack of mobility coming from the depletion of the quadriceps with rising age is one of the main reasons why many old people have such a shaky way of walking and moving.
2. You can stimulate extreme muscle- and strength gains while burning fat.
3. You can do them more frequently than any other (heavy) exercise.
The perfect squat
As I already mentioned there are many ways to do it. Also everyone has his or her own technique because of the anatomical differences and the mobility of the hips.
To teach a squat I start with telling people just to squat. When you do a squat without thinking about it as an exercise but as a necessary movement to put something in the drawer below your desk for example you will naturally go in your perfect squat position. When you fall trying it you should work on your mobility (https://www.youtube.com/watch?v=-ZXda1OqV4Q) and play a little bit with the position of your feet. Knees and feet should always point in the same direction when you do a squat.
But reading articles and watching videos are not enough. When you're not sure if you're technique is correct please look for someone who can teach you in persona. Safety first, especially when you want to lift heavy. Start with light weights until you master the technique.
Leg training
Not long ago when I trained legs I started with squats, then leg extensions and curls in super sets, then calves and then maybe even leg presses for the pump. After that I could barely walk for five days.
When I read about doing heavy squats more than once a week I thought these guys must be on steroids. How could I?
Then I left almost all isolation exercises and did only squats (maybe something for the abductors for knee stability) and realized that I don't develop this extreme muscle soreness I was used to even when the volume was high.
What do we learn from it? I don't say that isolation exercises and machines are bad. It's just the question what you want.
Why can I not do machine training instead?
After spending years in the gym my opinion is that these machines are for people who take bodybuilding seriously and not for untrained guys who want to build some muscle.
When you train your body you also train your brain. You want to train for muscle gains but are also interested in health and longevity? The natural movement squat is a complex sequence of tiny motions which your brain has to coordinate. On the machine instead the movement is given and you have to obey the machine - here your brain doesn't learn how to move the muscle naturally and the effect on your body and coordination will not be as powerful as it was with the squat.
How often?
Depending on your experience and working weight you can do squats from one time per week to three times per day. The best way to find out is to try.
For a beginner I would recommend one day (per week) in the gym with 5 sets x 6-8 reps.
When you have experience you could increase your squat days to 2 per week or more. After mastering the technique you should try sets with 1-3 reps.
So here is an example of your weekly workout routine:
Monday - heavy deadlifts
Tuesday - off
Wednesday - "light" squats 5 sets x 6-8 reps
Thursday - upper body (1*)
Friday - off
Saturday - heavy squats 3 sets x 6-8 reps + 2-5 sets 1-3 reps
Sunday - off or upper body (2*)
*your upper body could be one day push one day pull or both days full upper body (I like super sets with antagonistic movements) - one day light and one heavy
Depending on your other activities and your job this program can be very exhausting. You could skip one upper body day (then you must do a full upper body workout) or add one more light squat day if you need adjustments.
Squats are not too taxing for the central nervous system so you can do them very frequently but the exercise (especially with heavy weights) is still a lot of stress.
So when you had six weeks of consistent training you can take five to seven days off or do just very light workouts. Listen to your body. When you feel too exhausted and burned out take a break no matter what your workout plan says.
When you know a bit about exercising you will have recognized that this training schedule is very focused on the lower body. The reason for this is that the big lower body lifts (deadlift and squat) have the strongest hormonal response and help to develop upper body muscles, too. In my opinion the average gym Joe has to do a lot more of them!
Warming up
There are many fancy ways to mobilize your joints and warm up your legs before squatting. According to a well known youtube physical therapist and trainer Jeff Cavaliere (https://www.youtube.com/user/JDCav24) mobilizing can be a bad idea before squatting. Why? Because you get too mobile which could lead to injuries.
When you did a squat to pick something up you wouldn't do a mobilization warm-up, too, would you?
In my opinion the best way to warm up for squats is to do squats. Just start with light weights (baby;)