Snapchat can tell if you're driving because it can detect your location using GPS. If Snapchat detects that you're driving, it will automatically disable the ability to send or receive snaps.