Social workers can't just go to court to remove a child off their own bat. They will have needed to have sought agreement at a senior management level first and had legal advice. Most usually this will be done by the social worker and their manager presenting the case to a panel of people, often called Legal Gateway Mettings including legal and more senior management for discussion and all relevant assessments and paperwork being submitted beforehand for everyone to read.
In most cases the local authority would look to run Pre Proceedings first (used to be called PLO). This is where parents are advised to get legal representation and regular meetings are held with them and their legal rep to look at the concerns and review progress. Often there will have been a period on child protection prior. If Pre Proceedings don't work court is he last resort.
There are occasions where work can't be done before court, such as where the police have arrested parents and removed children or a single parent has been sectioned and there's no alternative but foster care. Or the pregnancy was concealed so no time ho work with the family. But on the whole there's a long journey before a case is presented to court.
Once it does get to court, parents have legal representation and a cafcass guardian is allocated to the child, who also has legal representation.
It's not just a lone social worker takes it into their head to pitch up at court asking to remove a child and the judge agreeing.