The 2 ㄱ's basically just show the syllables. So it's pronounced "hak-kyo" but when said it sounds like one ㄱ, or one fluent "hakyo". Similarly, many other Korean words are spelled differently than how they sound, such as "감사합니다", which is spelled "kamsahamnida" but sounds like "kamsamnida". This is because most people fluent in Korean speak fast, similar to english speaking people slurring their words when trying to rap. If you ever speak to a fluent Korean person, than saying "kamsamnida" would be fine, so in real conversation it's not that important, but more needed for writing or typing.
Short answer: that's just the way it is.
Longer answer. This word is Hanja based. 학 relates to study. 교 relates to school. There is no reason to change the way you write them when you put them together.
As for pronunciation, I'll let someone else answer. For what it's worth as a fellow learner, I mostly pronounce both ㄱ's.