While it might seem counterintuitive, the prefix "dis-" doesn't always mean "not" or "opposite" like it does in "disagree" or "dislike". In "discipline", it actually means "to teach" or "to learn" and originates from the Latin word "discipulus," meaning "pupil" or "learner."
The word "discipline" itself evolved from the idea of "teaching" or "training" someone to follow a set of rules or to learn a skill.