Let $q,p$ denote the position and momentum. Consider a transform generated by $g$:
$q' = q + \epsilon \{q,g\}---(1a)$
$p' = p + \epsilon \{p,g\}---(1b)$
Then:
$\{q',p'\} = \{q,p\}+o(\epsilon^2)+\epsilon \{\{q,g\},p\}+\epsilon \{q,\{p,g\}\}$
The last two terms vanish since:
$\{p,\{g,p\}\}+\{q,\{p,g\}\} = -\{g,\{q,p\}\}$
And $\{g,\{q,p\}\} = \{g,1\} = 0$
Therefore this transform generated by $g$ is indeed a canonical transform.
In the equation above we use the fact that $\{q,p\}=1$. However, this does not hold in general if $p,q$ denotes some other variable with non-constant commutator. In those cases, the commutator is not preserved!:
$\{q',p'\} \ne \{q,p\}---(2)$
But we already know that (1a) and (1,b) are canonical transform, which should mean that every commutator should be preserved, even if $q,p$ are not position and momentum, which contradict (2)!
What is going on here?? Is it a problem caused by the higher-order term $o(\epsilon^2)$?