It's my understanding (and I'm not positive), that when using programs in engagement programs, it works off membership of those programs. So when a cadence hits and a program is next, all of the applicable leads are added to that program, so regardless of whether they interact with the email or not, the next cadence will check to see if they are members of the program, and if yes, move on to the next piece of content.
I assume this would work the same if a lead becomes a member of a program outside of an engagement program, then is later added to an EP and hits that same program -- it would see the lead is already a member of that program and skip it.