You get to stay in the US for 1 year after completion of your course on an F1 visa. For students studying STEM courses, a new rule allows a 24-month extension, which means you can continue to stay in the US up to 3 years.
An M-1 Visa is meant for non-academic or vocational study or training in the US. Stay back period is actually equal to the duration of course in which you get enrolled, with an additional grace period of 1 month. The visa can be extended for another 2 years, to a maximum total period of 3 years, if this time is required to complete the course.