The verb, 'to nick' has meant 'to catch' since the 1600s. As such, it is easy to see how it came to be associated with the police and their 'arresting' habits! It was pretty straightforward thereafter for it to be used to mean the place you finished up in once they'd got you.