when is i8t ok to use M1V1=M2V2?

Anytime the acid/base is the same; i.e., a monoprotic base(NaOH, KOH, NH3, etc) with a monoprotic acid (HCl, HC2H3O2, HBr, etc). It also is ok if they are both diprotic or triprotic.

Diprotic acids are H2SO4, H2C2O4, etc) and diprotic bases are Ba(OH)2, Ca(OH)2, etc.
The other way you can tell is if the coefficients are the same. For example, if I write
NaOH + HCl ==> NaCl + H2O you could use that formula because the ratio is 1:1 and you can see that 1 mol NaOH = 1 mol HCl. For the equation
Ba(OH)2 + H2SO4 ==> BaSO4 + 2H2O you can use that formula also since the ratio is still 1:1. That is 1 mol Ba(OH)2 = 1 mol H2SO4. The coefficients still are 1 and 1. I hope I've made this clear. If not explain and I can go further.
You can use that formula, too, if you are making dilutions since reactions are not involved.