Yes for Australia, although it may take more than 5 years.
Student visa holders can apply for permanent residency (e.g. using the Skilled Independent (subclass 189) visa) once they graduate, if they satisfy the points test.
Student visa holders can also apply for temporary work visas after graduation, such as the Temporary Graduate (subclass 485) visa or the Temporary Skill Shortage (subclass 482) visa (if you have a job offer and the employer is willing to sponsor you). After they worked for a few years, their employer may sponsor them for permanent residency using the Employer Nomination Scheme (subclass 186) visa.
Once a former student has obtained permanent residency, they can apply for Australian citizenship in the usual way.
This page contains extensive statistics on Australia's student visa program, including their destination once they graduate.
However, in order to be granted a student visa, you must demonstrate that you are a "genuine temporary entrant", i.e. your intention is to leave Australia after you have finished studying. Nevertheless, as that page states:
The Genuine Temporary Entrant (GTE) requirement is not intended to exclude students who, after studying in Australia, develop skills Australia needs and who then go on to apply for permanent residence.