Male pattern hair loss is driven by genes and by dihydrotestosterone acting on susceptible follicles. You cannot switch that off with a shampoo. You can avoid making it worse: do not smoke heavily, do not crash-diet, and do not wear styles that pull the same hairs out for years.
Medicines such as topical minoxidil and oral finasteride are the treatments with the strongest everyday use for pattern loss. They are prescription decisions, in the case of finasteride, for your own doctor, because they have side effects and they only work while you take them. They do not bring back a hairline that has already become scalp.
A transplant is restoration, not prevention. Many patients do both: medicine to hold the hair that is still there, and FUE to rebuild the hair that has gone. That combination should be agreed with a doctor who can prescribe, not only with a clinic that operates.