Collisional excitation and ionization of K atoms by diatomic molecules: Role of ion-pair states