Count the cards that improve your hand. Those are the outs. On the flop, 47 unknown cards remain. On the turn, 46 remain. The percentage below is outs divided by the cards still to come, for one card, and one minus the chance of missing both cards when two are left.
The rule of 2 and 4 is the rough version: outs times 2 for one card, outs times 4 for two cards. It drifts at the edges. A flush draw has 9 outs. It is not a prediction, and it ignores the chance that the same card helps someone else.