I'm studying at a UK university too, and I always scratch my head as to how on earth people get the money to travel around Europe or Australia before they go to uni. Who funds it?
Generally, I think family does. Some families have more money than others. It also depends how much the parents are willing and able to sacrifice, of course.
The same way you might scratch your head wondering how some fellow students pay for rentals you can't imagine affording, and alcohol binges you can't imagine affording. Students from poorer families rarely go on gap years. But even some poorer parents will sacrifice a lot, if they can find a way, to pay for their children to travel.
That said, the costs aren't outrageous. Travelling around Europe or Australia is fairly cheap for a young person (or at least used to be). There are schemes to allow travelling costs to be lower for young people, visas tend to be cheaper and easier to get, and people do local, temporary work e.g. in bars in kitchens to supplement the money they brought with them, to make it last longer.
I went to university in the UK a long time ago. And I struggled to understand how people afforded gap years (or rent) then, too. I never had a gap year, and it makes me a little sad. But as I couldn't even afford to eat regular meals, and certainly couldn't join people for socialising when they went out to places like Pizza Hut (too expensive), it was the right decision not to take a gap year :/
There is a wide distribution of wealth in capitalist societies, and a lot of it is hidden from sight. Financing a relatively low-budget formative and educational gap year is something thrifty and financially conservative people would do for their kids.
I had my moments, worrying about a friend's finances and professional decisions, only to learn later that, well, there was clearly nothing to worry about.