What's the difference between 咁 (gam3) and 噉 (gam2)?
If you happen to be familiar with Mandarin or Standard Written Chinese, the Cantonese character 咁 (gam3) corresponds to 這麼 or 那麼 and 噉 (gam2) corresponds to 這樣 or 那樣.  As jogloran mentioned, 咁 is a prefix modifier whereas 噉 is postfix or a standalone pronoun.

You'll often see 咁 written where gam2 is intended, which is likely the reason why 咁 appears in your first example instead of 噉.  This is due to the fact that written Cantonese is not standardized, so some people are not necessarily aware of which character to use.  For consistency sake though, I always use 咁 for gam3 and 噉 for gam2.