the situation actually used to be far more complicated than it is now before 1962. At the time there were two different designating systems: one for the US Army Air Force (as the US Air Force was a part of the US Army until 1948), and a separate one for the US Navy.
The US Army Air Force (USAAF) had these P = Pursuit designations for its aircraft. This practice was introduced on 7 March 1925, when the US Army ordered the first series of 15 Curtis XPW-8B fighters under the official designation P-1. The same type, with some modifications, was then introduced with the US Navy as F6C, with the US Navy designating its planes according to the producer (in this case it was F=fighter, 6=6th fighter type by Curtis, C=third version produced). A good example for the USN designating system was the Grumman FF1: although built years after the F6C, it was the first fighter the USN purchased from Grumman, therefore F1 (which was later developed in the F2F that - via the F3F - became the F4F Wildcat after lots of further developement)
Sorry for the confusion, I was only refering to army aircorp planes since the P-38 was of that service. As you can read above there were duifferences between the US Navy and the US Army Aircorp designations and the US Army Aircorp didn't change the designation until after WW2
The USAAF then established a similar system for bombers, starting with the B= bomber, starting with the B-2 Condor, developed in 1924, but introduced in service only in 1929, and - sometimes in between also the A= attack designation was introduced, with one of the first "attackers" of the USAAF being the Northrop A-17.
Now, some classic examples of the USAAF fighter designations:
Seversky P-35
Curtis P-36 Hawk
Lockheed P-38 Lightning
Bell P-39 Airacobra
Curtis P-40 Warhawk, Mohawk, Tomahawk
Republic P-43 Lancer
Republic P-47 Thunderbolt
North American P-51 Mustang
Bell P-59 Airacomet
Bell P-63 Kingcobra
Northrop P-61 Black Widow
Lockheed P-80 Shooting Star
North American F-82 Twin Mustang
The last two were the last fighter-designs for USAAF which carried the P designation. Already the next Republic's fighter became the F-84, and North American then followed with the F-86. Both were, namely, introduced in service only after the USAF was taken out of the US Army and became an independent service. In the same move, also all the former Ps became F=fighters, so during the Korean War, the following designations appeared:
F-51 Mustang
F-80 Shooting Star
F-82 Twin Mustang