The reason written formally is for country defense but the reality of training details seem very far from cultivating military skills. The true reason I guess is to build up the authority of management group of the school/university. This makes it a lot easier to tell students obey orders in later school time. It’s natural for a student to obey orders later if in previous training they were taught to stand under sun for 3 hours without protection for no reason. That’s why military training always goes before students entering the school.