A guaranteed counterattack (or “counter for free”, “punishment”, etc.) is really a state where a counterattack is unpunishable, and thus one can theoretically assume that it can be taken advantage of (so, perhaps more like it is predeterminable than inevitable).
Essentially, after one blocks an opponent’s move, or after an opponent’s move whiffs, and when one confirms that this (or something like it) has happened, then if one can cut in with their own move during a certain calculated number of frames, there is a near-guarantee that this counterattack will work.
The logic goes something like: “(frame advantage) = (number of frames the opponent is out of commission) - (number of frames it will take one’s own move to start up)”; if the difference ends up positive, then one is in definite “frame advantage”, and the opponent is in “frame disadvantage”. And in “frame advantage”, one can use a guaranteed counterattack.
Knowing what leads to a guaranteed counterattack takes knowledge (e.g., testing the game thoroughly, or reading guides, or looking at frame data), and knowing when exactly to use it takes judgment and experience (which can only really be acquired by practicing).