Yes, Viagra (and now Sildenafil) are available from your GP. It is possible to get generic Viagra for free on the NHS. However, this is normally limited to around one box per month. Branded Viagra is no longer available on the NHS due to the higher cost compared to the generic alternative.
Many men choose to buy Viagra online from a reputable pharmacy rather than see their GP. This can be due to the larger quantities available privately, the ease & convenience of buying online, as well as the privacy of not requiring a face-to-face consultation.