He walked in the room. Li marsxis en la cxambro. He walked into the room. Li marsxis en la cxambron.In the first sentence, the phrase "in the room" tells where the action took place. He was in the room, and walked (he also spoke in the room, ate there, etc.). In the second sentence, "in the room" is the destination of the action, and thus the accusative is used.
The accusative of motion is also sometimes used without prepositions. For example, Li kuris hejmen is a common way to say "he ran home". In this case, hejme is the adverbial form of the noun hejmo, "home", and the final -n indicates that this is the destination of the action, rather than simply its location.