Let’s try to answer your questions:
- You can marry your girlfriend the moment you are in Canada – there is no residency requirement or other requirements as to length of time spent in the country, however each province does have slightly different marriage requirements and you should familiarize yourself with the correct requirements before travelling to Canada.
- Travelling to Canada on a study permit in order to get married and sponsored would likely be considered “misrepresentation” and therefore immigration fraud by Immigration, Refugees and Citizenship Canada. Will they find out? It’s hard to know. But if they do, you could have your sponsorship refused, or lose your PR status (or even citizenship, if you become a citizen) if this is discovered later.