In the case of due to:
Due
...is an adjective, and cannot be used as a preposition. A more correct term (closely related) would be owing to, which is grammatically correct. If you are strictly concerned about grammar then you will need to take that into account in your writing. Otherwise, it is natural to use due to.
"A differs from B due to X,Y,Z" ✓
In the above, we are saying that due to properties X,Y,Z a difference exists between object A and object B.
For is indeed a preposition (as you will see in most texts) however it is not the right word choice given the sentence structure and wording you have provided.
If you are looking to use for in your sentence, it can be used as a coordinating conjunction. This means it can be used to provide rationale between two phrases, sentences, objects etc EG
What is the reason that Jeremiah sliced his cat?
Jeremiah was hungry. Jeremiah then went and sliced his cat.
The reason (i.e. rationale for) that Jeremiah sliced his cat was, because, he was hungry.
We can then say:
"Jeremiah sliced his cat up, for he was hungry" ✓
You can use for in your sentence to explain that the difference between A and B is because of X,Y,Z however you would have to "elaborate further" to provide a rationale for such a distinction eg:
"Mineral water differs from distilled water, for the presence of [X],[Y],[Z] in mineral water give it a different boiling point/texture/reactivity"
In the example above using the word for, we have achieved the same thing as we did using due to. However, you can see that it is much more natural and easier to use due to in this case because the sentence will not be as long.
I would use because:
Mineral water differs from distilled water because of the presence of minerals.
in other words:
"A differs from B because of X,Y,Z" ✓