A good hacker who is looking for something specific and not there just to cause trouble, as many people think of hackers, will leave extremely little trace of his presence.
Ultimately it comes down to someone noticing something strange on their computer systems, either from logs of connection attempts, or from missing/new files. From there they might be able to trace the connections made to their computer to, say, a place where the hacker had passed through a proxy. Proxies create facades that people using the internet can mask themselves with, and it's possible to tunnel through several proxies to obscure yourself even more. Basically, it's all about finding little clues along the way...little things that somehow got left behind, and that give hints as to where they came from...bits and pieces of files. A lot of times it will lead to dead ends, and a lot of other times it will lead to public places where the person was able to get on to the internet without allowing his identity to be revealed...which then turns the case into a police case, because they're looking for someone who was there at some point. A lot of times, though, the trail will end at a random person's internet connection, an internet connection which the hacker had spoofed.
There's no real way that the government cracks down on hackers, it's just a matter of lucky clues and unavoidable mistakes on the hacker's part. It also happens that former hackers will become consultants, and work with big companies to safeguard their computers and data. Since these guys used to do it themselves, they know of the back doors and secrets that hackers like to use, and can sometimes spot when one has been used.🙂