There's a pretty major grammar error in the sentence you are asking about. You said:
私は山田さんとジョンさんに行きました。
The problem here is with the particle に, as it treats John as a place. に is a particle with a variety of uses, I'll list the ones contained in A Dictionary of Basic Japanese Grammar (Makino and Tsutsui).
- A particle that indicates a point of time at which something takes place.
- An indirect object marker.
- A particle that indicates an agent or a source in passive, causative, morau ... and other receiving constructions.
- A particle that indicates the surface of something upon which some action directly takes place.
- A particle which indicates purpose when someone moves from one place to another.
- A particle which indicates the location where someone or something exists.
Of these various uses of に, the use that best applies to your sentence is number six. The sentence given is grammatically incorrect because John is not a place, but a person. If we were to edit your sentence like this,
私は山田さんとジョンさんのアパートに行きました。
we have a grammatical sentence. In this case, the use of と in this sentence would be either of your two options. In one case, it would be:
I went to Mr. Yamada and John's apartment.
In the other case, it would be:
I went with Mr. Yamada to John's apartment.
The only way we can determine which use of the particle と that we are using will depend on the context surrounding the sentence. If this sentence were spoken on its own, you would put a slight emphasis on the と to indicate that you are going with Mr. Yamada to John's apartment. Context matters a lot in Japanese.
If we were to edit this sentence to be grammatical in another way,
私は山田さんとジョンさんと映画館に行きました。
I went with Mr. Yamada and John to the movie theater.
we have use of both of the と particle definitions.
Long story short, this isn't an issue with the particle と so much as it is an issue with an ungrammatical use of に.