The Flame didn't became a new Lavos. We've always been dealing with the same one.
Once more, the Machine was never involved; and there was a Lavos present. The one defeated in Trigger.
That is what pretty much what happened. During the Ocean Palace events, Schala got sent to the DBT. Later, Lavos is defeated but instead of dying is also sent to the DBT. How or why? It's not said clearly. Lavos itself has some spatial and temporal powers, perhaps that was it, who knows. Then, somehow, it decides, or it happens somehow on its own, merges with Schala who is already present there as well. Once again, no Machine involved.