I'd always heard is was an army saying, but the only thing a quick search yielded was:
"Proper Planning and Preparation Prevents Piss Poor Performance” is known as the “7 Ps.” There are many variations of this expression, such as “5 Ps” and even “12 Ps.” The expression is believed to have originated in the military during World War II.
“In marketing efficiency, the five P’s — an infantry division slogan in World War II — Prior Planning Prevents Poor Performance” was cited in print in 1956. “Proper Planning Prevents Poor Performance” was cited in print in 1961. “The PPPPPP factor applies: ‘proper preliminary planning prevents poor performance’” was cited in print in 1966