Australian slang from the gold rush era. Originally referred to police officers who would go around the gold fields to inspect gold mining licences who would use any excuse (such as your licence was not on your person) to arrest (or "trap") you. Later used for the police in general.