Why did we have millions of them in stock already, when until 2020 virtually nobody had heard of them? Those things were all over the place like those silver bottles thrown on the street by naughty teenagers. I'm sure you were familiar with them being a medically knowledgeable person, but ask the average man on the street New Years Eve 2019 "have you ever heard of or experienced a lateral flow test" and he'd give you a blank look.
The basis of the PRC tests is as has been said decades old, once they ID'd the virus it was a matter of adapting the test which is trivial as PCR/Lateral flow is the technology/method not what it's testing.
You've possibly never heard of a PCR test before because you're not a medic or work in a lab that use them?
Yes the average person in 2019 wouldn't have a clue about lateral flow, they also wouldn't be able to tell you the names of half the machinery in the average doctors surgery including what a sphygmomanometer is if you asked them. IIRC the PCR test is basically the same technology that the police use for various things, it's just known by a different name to them (usually related to what it's testing for*)
IIRC they've been using them in labs and for fast response tests for the Flu etc for a long time (apparently the first commercial machine was out in 1985 and was used for a very different disease to covid), hospitals have used PCR tests for a very long time now to work out if a patient was potentially infectious with various different things without the need for a lab test, for example there are versions of the kit that can tell you if you've got Flu type A or Flu type B as all it requires is the little strip to have two of the PCR test lines one for each, rather than one "test line" (I think you can now get a three way test that also does covid).
The reason they were able to get them onto the street within months was because everything bar the actual PCR reaction chemical specific to the Covid virus was already available, so once they had that chemical sorted out they just had to apply it to the "paper" strips already mass produced, fit it in a cheap injection moulded casing and package it up (and the amount needed per test strip is so tiny that a litre of the specific chemical probably does thousands of strips).
Literally it was one chemical needed to be changed for a product that they already made, and some new graphics for the packaging.
Basically they took something that was normally only used "behind the scenes", and made a mass distribution consumer packaged variant.
Sorry if I'm coming across a little harsh but this is a great example of how a CT theory starts from the wrong assumption and a lack of knowledge of what the thing actually is.
[edit]
I see a few replies with other uses of the same technology, I should have guessed the modern pregnancy test was one of them.
*Apparently the first medical use of the technology was sickle cell disease, then it started to be used in police work within a year or so for forensics (I'm guessing probably a quick blood typing, or drug test).