Why are vets so expensive?

We’ve just been charged £38 for a 15ml painkiller for our dog. I can get the same one, only 30ml for £10 online. It’s actually disgusting. Does anyone know why and how this is allowed?

Our vet also charges £30 for a prescription and the consultation fee is £50.

I’m based near Glasgow

edit

thank you everyone for the replies - really helpful. I can understand the running costs of the vet and why that would contribute to higher costs. Also that we’re too used to the NHS so we don’t see how expensive medical care truly is. Lots of you suggested trying other vets but unfortunately there’s only two in my area.