K is towards, in the direction of and it takes dative case. B is in(to), inside, to (as in inside) and it takes accusative. к школе would mean towards the school (we are going to meet someone in front of the school so we are going towards the school. people are walking towards the school/ went in the direction of the school). в школу is to school in literal or educational sense, regardless of the way there. The problem is they can both be translated with to school, but they don't mean the same thing.
к школе should be translated as "to the school," and в школу as "to school." English is weird that way. The article actually indicates the reason one is going. Without the article, it is for a class. With the article, it is for some other reason -- a game, a meeting, practice, etc.
We have the same with "to church" versus "to the church." Without "the," we are going for a religious service. With the article, it is for some other reason -- choir practice, Boy Scout meeting, etc.
Pfffff before I translated идти к школе as "... going to the school" and it was marked as wrong because it said it needed to be "to school" without the "the". Now I translate this sentece as "... going to school" and it is marked wrong, it says it should be "to THE school". What the heck? It's just so frustrating.
hello everyone with russian prepositions v/vo and k/ko and o/ob have to do with spelling and vowels, if I am correct. I am working off memory and have not looked it up in some time, and sadly forgot the exact rule at work.