You're having the problem because most of E-D's encodes are vfr (variable framerate)...
So if you simply demux, and later remux the streams, of course they're going to be out of sync...
You have mkvtoolnix? Good, now get the add-on mkvextract to it unless you already have it, and extract the timecodes file from the original file.
When you mux back, just add the timecodes file (there's a selection for it on mkvmerge front, if you're using the gui), and voila, the remuxed file should be in sync

One problem you might also run into is if the audio is tagged with delay, but you should see what the delay is in the demuxed streams' names. If needed, just fill the right prompt in mkvmerge when remuxing with those values...
As for vfr, it's probably a lot easier to understand if you approach it from a completely different angle and forget all about normal framerates...
Think of it as a set of frames with each having a set time to appear on the screen, and the player reads those times from the timecodes file where they are noted for each frame.*
(*...if the timecodes file is v2 format, and that is what you get if you get it with mkvextract).
Most times vfr/variable framerate doesn't refer to encodes with very varying times for the frames globally (true vfr), but to encodes with both 24 fps & 30 fps sections, such E-D's encodes...