Ran some tests with this mechanic over the course of 3 separate runs (trying different scenarios) and here are the results I got.
This is all post-fix (supposedly)

On first instance
Stood still from cast until damage taken (as a control)-> stack of debuff
Started running during cast until damage taken -> stack of debuff
Started running after cast until damage taken -> no debuff
Started running before cast until damage taken -> no debuff

On second instance
Stood still from cast until damage taken (as a control)-> stack of debuff
Started running during cast until damage taken -> no debuff
Started running after cast until damage taken -> no debuff
Started running before cast until damage taken -> stack of debuff

On third instance
Stood still from cast until damage taken (as a control)-> stack of debuff
Started running during cast until damage taken -> stack of debuff
Started running after cast until damage taken -> stack of debuff
Started running before cast until damage taken -> stack of debuff

---Analysis---
I know 3 runs is hardly a proper sample, but from what I can tell the only certainty with this mechanic is the control. If you don't move, you will get a stack. As far as anything else goes, it just seems like pure RNG to me. Some fights I go with only 1 or 2 stacks so I think I have it figured out. I try reproducing the result the next run and end up frozen over and over. I honestly have no idea at this point if there is a definitive way to dodge this mechanic.