Where trains are operated with guards/conductors, they are jointly responsible with the driver for the safety of the train. Their primary role is safety- in some parts of some companies (South West Trains on the inner-suburban routes for example) they may have no role whatsoever in revenue enforcement.
if a route/company has guards, they are required to be on every service. Without the guard, the train will not run. Very often the train couldn't run- the driver may not have controls for the doors and/or a safe way of observing the doors when closing them. On Driver Only Operation routes you may notice a bank of mmonitors at the end of the platform plus cameras along it, or big mirrors. Alternatively at some stations the driver may be able to look back out the cab window, or on modern stock they may have cameras mounted on the train with monitors in the cab.
On DOO routes, and also on routes with non-revenue guards, you'll get Revenue protection/enforcement inspectors/officers (the terminology seems to vary?). They're solely responsible for checking tickets. They don't have to be on every train (they'll be on a small % of them) and tend to operate in pairs from what I've seen.