Swiss people are obliged to pay taxes in their canton of residence. This rule is applicable to students as well as any other person. However, because students often live with their parents on the weekends but may have a room at their place of study during the weekdays, it can be difficult to determine their canton of residence. The decisive factor here is whether students return to their family and friends every weekend as weekly residents, or whether they only see their family a few times a year. If they return regularly they may file a tax return in the canton their parents live in, otherwise they need to pay taxes in the canton they usually reside in.
An explanatory example:
Tim, Manuel and Martina attended high school together in Zurich. For their studies, Tim and Manuel decide to go to the University of Bern, while Martina attends the University of Zurich. Martina is therefore liable to pay taxes in Zurich in any case, whereas for Tim and Manuel it depends on their centre of life.
Let's assume that Tim builds up a new circle of friends in Bern and only very rarely goes back to Zurich to visit his parents, while Manuel is in Zurich every weekend. This means that Manuel continues to be liable for taxes in Zurich as his centre of life is Zurich, while Tim now needs to pay taxes in Berne.
However, it is notable that because students often do not have a high income or a lot of assets the cantons usually do not apply these rules too strictly, but rather accept it when a student files a tax return in either one of the two cantons in consideration.