This is all decided by the KSHSAA. They basically divide the state into four geographic regions and whatever region a town falls in is where they go. This is a little simplified but basically correct. The state also makes no bones about the fact they want to get "the best kids from the four regions of the state"-not necesarily the best kids in the state.
I think it's almost like football sub state if I'm not mistaken as well with the geography changing every other year. Like you might end up in the NW this year and then the SE next to change it up. If you are a team that falls on the middle of the geographic cut, sometimes you get tossed wherever. I personally like when leagues get split up a bit that way you don't see the same old guy at regionals.