I doubt it was the shot if you're getting it from a reputable doctor or pharmacy. I've been taking B12 shots, weekly, for Pernicious Anemia, for many years and have never had a kidney infection.
Just for your info, they don't help with weight loss anyway.
I have also just had 2 b12 shots over course of 2 weeks. I suddenly developed bladder inf then kidney infection later the same day! I have taken b12 shots before, even daily, with no prob, but it's been several yrs. I haven't had a kidney inf in many yrs, was extremely hydrated, eating very healthy, so see no reason for it other than maybe suspecting the shot. Wonder if there are other ingredients in the shots, like preservatives, that could be the real cause?