4 Digit 7 Segment Display randomly turning on and off for no reason

But there just miliseconds and it turns off for a second or two.
And how would I do it without a delay? If I didn't have delays between turning on each digit it would only turn on the last one, right?

And as I said, the bug only appears with certain combinations of numbers. For example, Display(2,2,2,2) works fine but with Display(2,2,2,7) it starts turning on and onff again. This really makes no sense to me.