Anyone in the UK interviewed by the police is entitled to free legal advice - which is often provided by the duty solicitor from one of many local firms. Sometimes it can even be one of their legal reps - not a full solicitor, but trained to give advice.
People in the UK generally don't have their own solicitor for criminal matters, but may choose a specific firm if they've been in trouble regularly
If the case is heard at a lower court, called the Magistrates, the solicitor will represent them. If the trial is escalated to the Crown Court, they will be allocated a barrister free of charge. If the trial is serious, such as murder, you can have what's called a Silk allocated (Kings Counsel) these are senior barristers.
You can pay for better solicitors/barristers to represent you