The key point is the position of 了.
1.1 used for actions or changes that have actually occurred
我去了学校=I have been to school.
1.2 for expected or hypothetical actions
2.2 Indicates that a situation has occurred or is about to occur
我去学校了=I am going to school.
In fact, we usually say “我去学校了” to parents when we are leaving home for school.
If we are asked where we have been, we are suppose to say "我去了学校". “我去学校了” also makes sense, which did not conform to the grammar, just because it conveys the place.