1. He fought with one of them.

2. He fought against one of them.

3. He fought with wild animals lonely.
4. He fought against wild animals lonely.

5. During the war, he fought with his comrades.
6. During the war, he fought against his comrades.
-----------------
#1 is #2. #3 is #4. Is that right? What about #5 and #6? Does #5 mean #6?

1 and 2 are fine.

3 and 4 would be fine if "lonely" were omitted.

5 and 6 mean two different things.
5 means he and his comrades fought a common foe.
6 means he and his comrades fought with each other.