It's strange I can't find a duplicate and I believe there is one. I will try my best to explain it, but it is not easy.
The preposition with has a very important function as the below definition indicates:
used as a function word to indicate an attendant fact or circumstance: 'He stood there with his hat on'
The attendant circumstance means an accompanying circumstance. In other words, the action (or state) described after "with" is happening at the same time (usually).
The example in the block quote above could be rephrased to:
He stood there and he was wearing (on) his hat at the time (he was standing).
The company took the first place and their competition took a distant
second (at the time the company took the first place).
North America had the greatest number of travelers over the 5 year
period and Central and Eastern Europe showed a similar pattern (at the
time North America had the greatest number of travelers...)
When you have something, you are with something. If two things happen at the same time, one thing is happening with the other.
Some more examples:
The matter was resolved with both countries cooperating.
She sat silently with the cat dozing at her feet.
The man is leaning against the wall with his arms folded.
You need to read as many examples as possible and get yourself familiarized with them.