No, Its not mandatory to take 2 years of course. If your course is of 8 months or more than that then you will get post grad work permit.
But most of the people choose 2 years because after completing 2 years of course they may get work permit of 3 years which is more convenient way to get PR.