Simply put, idioms are the way we say things, and there’s no rhyme or reason to them. Prepositions, for instance — those little words like in, on, by, with, for, etc. — they tend to be the most idiomatic parts of speech.
Take the word “with” for example: depending on the context, it can mean exact opposites. If a man says “I fought with the Germans in World War II,” we understand that to mean that he fought on the side of Germany. If a man says “I fought with my wife last night,” it’s unlikely he was on her side.