Since Generation 2, you cannot use Transform twice in a battle. So if Ditto transformed into Mew or vice-versa, neither pokemon can use Transform again.
In Generation 1, if Mew transformed into Ditto first, then Transform now will just turn Ditto into Ditto. It would be a never ending battle because they only know Transform and the PP never runs out.
If Ditto transformed into Mew first then you'd have 2 Mews. If either uses Transform they stay as Mew (but their PP is reset).