A programming logic error or bug in terms of video games is a programming blunder in the game code that prevents the game from doing what it was supposed to do (i.e. the intended behavior by the developers). The word "bug" is widely used in the context of programming in general, but not used as much in the context of the Pokémon series, partly due to the possible confusion with the Pokémon type.
In many cases, when a bug is initially "found", it isn't actually located in the game code. Instead, what is actually found is a series of steps that allow reliable reproduction of an unintended behavior (i.e. a natural glitch), which indicates that at least one bug must be triggered during the steps. In the absence of knowledge regarding the actual underlying bug, the entire procedure may be referred to as a "bug"; however, this is inaccurate, and might be changed when the underlying bug is pinpointed.
Note that sometimes a bug can manifest in different enough ways, such that they are considered multiple natural glitches. For example, the same bug in the wild encounter checking code causes both the Viridian Forest no encounter grass tiles glitch and the left-facing shore tile glitch (including its more well-known variant, the old man glitch).
Sometimes, it can be difficult to infer the actual intended behavior by the developers. For example, in Pokémon Red, Blue, and Yellow, the Focus Energy glitch causes the critical hit rate of a Pokémon that has used Focus Energy to be
BaseSpeed / 2048, lower than the unmodified value
BaseSpeed / 512. This is most likely unintended behavior, because the move Focus Energy increases the critical hit rate in all other games. However, it is unclear whether the intended critical hit rates are:
BaseSpeed / 512 without Focus Energy, and
BaseSpeed / 128 with Focus Energy;
BaseSpeed / 2048 without Focus Energy, and
BaseSpeed / 512 with Focus Energy.
In the former case, the bug affects damaging moves used under the effect of Focus Energy; in the latter case, the bug affects all damaging moves used. The situation is further complicated by Pokémon Stadium (which is usually a good indication of intended battle mechanics in Generation I) using a completely different critical hit rate formula instead.
As such, the exact scope of bugs, or even whether an unintuitive behavior is a bug, may not be completely clear-cut. Sometimes community consensus may be needed to decide on those points.