When you fret a string its effective length changes. It becomes shorter and it's thickness becomes greater in proportion. And yes, intonation is the reason the 12th fret marks the approximate midpoint. And FWIW, compensation is based on the thickness of the string's core. That's why an unwound 3rd string, which is all "core," requires more compensation than an otherwise thicker, wound 4th.