This is a lateral flow assay.
[image source]
A sample is applied at one end of the strip and flows across to the other side by capillary action. It first encounters antibodies against the target antigen and which are conjugated to some reporter (in the image above, the reporter is colloidal gold). When the sample contacts these antibodies, they too will begin to move across the test strip. If the target antigen is present in the sample, in your case COVID, these antibodies will bind to it.
The sample then crosses the test line. The test line contains antibodies, immobilized to the strip, against the target antigen. If the sample contains the target antigen, it will bind to these antibodies and stop moving. Since the antigen is also bound to the reporter antibodies encountered earlier, these antibody/reporter conjugates will become concentrated at the test line and produce a visual change on the strip.
Finally the sample encounters the control line. The control line contains antibodies against the reporter antibodies. Regardless of whether the target antigen is found in the sample, the reporter antibodies will bind here and produce a visual line. The purpose of the control line is to give a visual indication that the sample has in fact travelled across the whole strip.
In a negative test, the lack of antigen means the reporter antibodies will not stop moving at the test line and will only be bound at the control line.
There are several possible reasons for a failed test (when no lines are visible or the test line is visible and the control line is not). Among these, it’s possible the sample has simply stopped migrating across the strip before reaching the test and/or control lines. Or it could be that the antibodies have degraded due to improper or prolonged storage such that they no longer bind properly.
Note that this answer is just a general description of a sandwich lateral flow assay. There can be variations of this procedure in specific tests.