There’s a joke that has been circulating for a while now about Breaking Bad being a prequel to Malcolm in the Middle, the theory being that Walt goes into witness protection and ends up as Hal. However, I think a better explanation is that Breaking Bad is actually a sequel to Malcolm in the Middle.
The first two points are very obviously covered by setting Breaking Bad as a sequel, the timelines are plainly in a more logical order.
To address the other point I would argue that Walt is not Hal but an older Malcolm. This just makes far more sense; Malcolm is a genius with plenty of chemistry experience - he even uses a chemistry set to make a small explosion in one episode.
Comparing the two characters personalities you see that they are both incredibly intelligent, stubborn and manipulative. They can both be violent and selfish but have some small supply of morality deep down. Malcolm often displays the ability to devise intricate plans that made Walt so successful. Also there is a small reference early on in Breaking Bad to Walt not caring too much for his mother which fits nicely.
Finally we know that Malcolm will probably look quite similar to his father when he’s older.
The only inconsistency is in the name, this is where some wild fantasizing has to be done. The obvious answer is that Malcolm changed his name at some point I can’t really offer anything solid beyond that.
It is interesting to note that Hal’s father in Malcolm in the Middle is named Walter, in the episode “Family Reunion” it is shown that he is an avid history buff and he seems to be one of the few family members who openly appreciates Malcolms intelligence. It’s not too far fetched to guess that Walter is Malcolm’s middle name, this is a common custom is some families, and maybe Malcolm starts to go by this name as a tribute to his grandfather.