The particle を is used with certain verbs of motion, such as 行く, 歩く, and 走る, to indicate where someone or something moves through. It is said to indicate a point of passage. It doesn’t matter whether that point is expressed in absolute terms or relative to something else.
The particle に, on the other hand, is used with verbs that describe the presence or existence of someone or something, most typically いる and ある.
〜の前に歩いていました is not totally wrong because of the compound form 歩いている, but its focus is on いる (presence) rather than 歩く (motion).
I can think of an example like this.
Although this sounds a bit awkward and is probably considered ungrammatical, it’s understood with little difficulty in everyday conversation. The main point of the main clause is that there was a beetle in front of the house. It happened to be walking but was, for the obvious reason, too slow to look “passing” in front of the house when you found it. It’s hard to imagine a similar situation with people walking.
You can still use を to describe the same scene.
Actually, this sounds more natural however slow the beetle may have been. The sentence puts greater focus on the passing of the beetle, and that’s usually what you would expect when you choose to say
歩いていました instead of just
By the way, で may also be used with 歩く.
In general, this particle is used to indicate a place where some action occurs, and therefore, the above sentence puts greater focus on the beetle’s action of walking and where that was happening, compared to the earlier sentence with を.
When 歩く is not in the form of 歩いている but in its basic form (i.e. 歩く), it is not usually used with に.
The most natural choice would be を.
You could use で but it changes the nuance.
In this sentence, walking is seen as an action in its own right, or something you do for the sake of it, perhaps as part of your physical exercise, rather than as a means of moving from one place to another, and that action takes place within the boundary described as
に is not usually used with 歩く even in cases where that に would indicate a destination.
駅に歩く sounds weird.
駅まで歩く sounds much more natural.