(If you're about to leap up and start going on about the scientific method, bear in mind that the difficulty in doing this properly and the rather extreme efforts that must often be undertaken to conduct the "same" experiment precisely because it is not a thing that happens automatically is itself testimony to how correct I am here, not a contradiction.)
There's a distortion introduced by English here which implicitly draws a dichotomy between "doing the same thing" and "doing the different thing" as if this is drawn from a set of two possibilities, but in fact there's a whole universe of possibilities of which "the thing you just did" is a tiny particular point. Both these formulations are actually correct because if you are doing a thing that is failing and has failed several times, there is quite likely no particular reason to believe that the world around you is going to change in the probably-very-precise way necessary to make it work. But as the world changes, the "same" thing you've been doing is also likely to go out of date because over time, it isn't the same thing. You may be performing the same action, but the context has shifted and the world is no longer what it was back when your action worked.
Anyhow, I just avoid the saying entirely. It is very rarely usefully applicable.