It depends on the situation. For conditions like penile cancer, surgery may be the only treatment option.
But for conditions like ED, a number of therapies can be tried first. Some men do well with medications, vacuum devices, or penile injections. Usually, surgery isn’t considered unless these therapies are inappropriate or unsuccessful.