How can pyelonephritis be caught?

Its complicated. 2 factors promote pyelonephritis. 1) bacteria must invade the kidney. 2) a person's immune system must fail to some degree. Bactereia are common in the urinary tract. But if large amounts of harmful bactereia enter the kidney during lower urinary tract infections or during kidney obstruction (ie. Pregnancy, injury, surgery, congenital disease, or poor bladder emptying), pyelonephritis may develop.
Caught = detection. If you mean "how is it detected?" that is another story. While there are several types of pyelonephritis the most common is an acute form due to bacterial infection. Generally, it is a clinicians suspicion for the infection that leads him or her to make the diagnosis and begin treatment. Clinical symptoms (pain, fever, weakness), abnormal blood and urine tests and ultrasound technology are useful.
Pyelonephritis. Pyelonephritis is caused usually by enteric bacteria (eg. E.Coli) that reside in the perineal area. For many reasons, some strains of bacteria become pathogenic and "climb" up the urinary tract (urethra, bladder and ureters) to the kidney, causing pyelonephritis.