there is a motion in this sentence. why dont we use melle instead of mellett
They can all be in motion.
In Turkish for you:
mellé - yanına - to a place next to
mellett - yanında - at a place next to
mellől - yanından - from a place next to
The train is in motion at a location which is next to the station. "Az állomás mellett".
No, it is not a matter of logic.
If you stand next to me, then you are walking away from me, then it is "mellől".
If you are walking behind me and then pass me because you are walking faster than I am, then it is "mellett".
The same goes with the train. On its way from point A to point B, it "elhalad az állomás mellett". If it was waiting near the station, then started moving again, then it "elhalad az állomás mellől". One is "pass by", the other one is "depart from".
Actually, according the logic of Turkish, you are right, of course. Turkish would use "yanından" - "mellől".
But the logic of Hungarian is a bit different here. According to the Hungarian logic, the place where the passing happens is next to the station. So, Hungarian uses "mellett" in this case.
Actually, English thinks similarly. The train does not pass "from the station" but, rather, "by the station". "Az állomás mellett."
It reminds me of when I was struggling with the "át-" preverb: "Átmegyek az utcán." didn't seem very logical to me.