A query from a student is interesting:
“Since bersama may be with then can we interchange them.”
Only to a certain extent.
Bersama is simplified from bersama-sama which means [together].
[together] implies /with/ another person
Dengan is [with], a logical relation between 2 things/persons.
Hence you can interchange them in this example:
1. Saya pergi ke pasar bersama/dengan seorang lelaki.
I went to the market with a man.
But you cannot interchange them in this example
2. Dia pukul saya dengan [*bersama] sebatang kayu.
S/he hit me with a stick.
A & B going to a location [together] implies [with] each other hence the interchangeability.
Hitting X [with] Y blocks the reciprocate meaning of [together].