In Berlin, they usually enter the train in groups of 3-4, so they are able to check every person in one wagon in between two stops. You also see them pretty often at a station collecting the details of someone who didn't have a ticket.
I think both of those factors push most people in Berlin to buy a ticket. With a fine of 60 EUR the staff already pays for itself if they pick up ~2 people/hour, which sounds very realistic. If they then on top also have the effect of increasing the percentage of paying riders by a tiny amount, the whole program is quickly turning a profit.
Consider this article from Berlin where a sizeable number of people in jail are there for riding without a ticket.
The cost of that needs to be taken into account here.
It's extremely rare that that happens. It's typically considered a criminal offence if you are caught twice in two years, but rarely anyone is following up on that. Only really frequent repeaters are really prosecuted.
I think both of those factors push most people in Berlin to buy a ticket. With a fine of 60 EUR the staff already pays for itself if they pick up ~2 people/hour, which sounds very realistic. If they then on top also have the effect of increasing the percentage of paying riders by a tiny amount, the whole program is quickly turning a profit.