These are fixed expressions. They are not governed by grammatical rules. They have to be memorized as idioms.
Note that these in the first group all refer to activities, even if indirectly.
at school, to school, from school, in school
at work, to work, from work
at church, to church, from...