A brief diachronic analysis
It descends from Proto-Germanic *withro (corresponding to Modern German wider 'against'), but took on additional meanings in Middle English when it replaced the now-obsolete mid, descended from Proto-Germanic *midi (corresponding to Modern German mit 'with'). Since it now appears both with and without oppositional meaning, in Modern English it makes sense to assign any oppositional meaning to the verb it appears with rather than the preposition itself.
A synchronic analysis
In your examples the preposition with is comitative, indicating that at least two participants together play the same semantic role. In the case of fight with, for example, it indicates that both participants are fighting.
However, the oppositional meaning comes from fight, not from with.
Take a look at this example from Wikipedia:
The term “Companions of the Conqueror” in the widest sense signifies those who planned, organised and joined with William the Conqueror, Duke of Normandy, in the great adventure which was the Norman Conquest of England (1066–1071). The term is however more narrowly defined as those nobles who actually fought with Duke William in the Battle of Hastings.
Here, the nobles were companions of the Duke. They were fighting alongside him, not against him. Despite this, fight with is appropriate. In this example, the object of with isn't in opposition to the phrase it modifies.
Sometimes, though, it is:
I fought with my sister today.
Here, my sister and I are the only two participants. Since the semantics of fight require two opposing sides, there's no way we could have fought on the same side―we naturally understand that my sister and I were on opposing sides when I say this sentence. Any other interpretation is unlikely (unless we have some additional context to suggest there were other participants).
The same thing isn't true of the Battle of Hastings, which had far more than two participants. The semantics of fight don't require that the opposing side is specified using with, they only require that an opposing side exists. This allows us to interpret fight with as meaning "fight alongside" in the Hastings example.
Verbs like study and go are different:
I studied with my sister today.
These verbs have no semantic requirement for opposition, so naturally phrases like study with lack any oppositional meaning. The preposition itself no longer carries this meaning.