How is this possible from something topical![]()

Finasteride (Propecia, Proscar): Uses, Side Effects, Interactions, Pictures, Warnings & Dosing - WebMD
Find patient medical information for Finasteride (Propecia, Proscar) on WebMD including its uses, side effects and safety, interactions, pictures, warnings, and user ratings

Finasteride is a pill, the topical stuff is minoxidil
Hair loss prevention isn't its main use, that's just a welcome side effect.
"Finasteride is used to shrink an enlarged prostate (benign prostatic hyperplasia or BPH) in adult men. It may be used alone or taken in combination with other medications to reduce symptoms of BPH and may also reduce the need for surgery.Finasteride may improve symptoms of BPH and provide benefits such as decreased urge to urinate, better urine flow with less straining, less of a feeling that the bladder is not completely emptied, and decreased nighttime urination. This medication works by decreasing the amount of a natural body hormone (DHT) that causes growth of the prostate.Finasteride is not approved for prevention of prostate cancer. It may slightly increase the risk of developing a very serious form of prostate cancer. Talk to your doctor about the benefits and risks.Women and children should not use this medication."
Edit:
Also, I read long ago that the removal of testicles also prevents hair loss, I'm not going to google that to confirm for obvious reasons, but if you take that into account with what this medication does, you can understand why it probably prevents hair loss.
