1. My home is about 2KM away from the school. = you have already mentioned the school the reader or listener knows which/what school's being referred to.
2. My home is about 2KM from my school= you make it known it is the school you attend, being referred to.
3. My home is about 2KM away from school. = same as 1 the reader or listener knows what school is being referred to.
4. you can also say our school, their school, your school.
Depending on which perspective you are speaking from it can be just "school" or "the school". Best choice is to always use "the school" after first of all clearly stating your perspective and relationship to "the school".
You have to tell the reader or listener, are you a teacher there?, do you work there? are you a student there?.