Your original formulation was not very clear; I will answer your question as I understood it.
Sentence 1: The order of the two phrases auf dem Weg zur Schule and mit seinen Freunden is arbitrary. You can equally well say Tim ist mit seinen Freunden auf dem Weg zur Schule. The order depends on where you want to place the emphasis, on his location or on the fact that his friends are with him. Please note that they are not objects, they are adjuncts. You can leave them out without much changing the meaning of the sentence. Obviously one of them needs to remain for the sentence to work.
Sentence 2: There are two readings here. The first, more obvious one IMO, is that there is a house with a dog, and he does not want to walk past it. In that case the whole lot is a single phrase, das Haus mit dem Hund. It is in the dative because of the preposition an. There is no possibility of swapping the order of the two elements.
The second option is that he is walking the dog, and he does not want to walk past that particular house. In that case it would be preferable to say damit er nicht mehr mit dem Hund an dem Haus vorbeigehen musste, to make it obvious that the dog is not part of the house. So here you have a free choice, but depending on the meaning there is a strong preference for one of them.