In reality of course this trope makes very little sense, or at least requires an absurd amount of hand waving to justify. Artists who utilize this trope rarely stop to think that a solid state microchip might favor appreciably different logic than that of an organic bio-electric human brain. We're just supposed to assume that everything which has a certain amount of raw intelligence is automatically going to look human and fit neatly within Maslow's Hierarchy of Needs. On a more practical level, the reasons why people decided to design and mass produce human-like robots are usually reduced to them being stronger or more efficient than humans, but that only raises additional question of why they spent so much effort trying to cram all that physical capacity into the human form in the first place instead of drawing up designs which make slightly more sense in engineering and economic terms. And why they decided to give these expendable grunts and mining robots complex neural networks and baby blue eyes in the first place is anybody's guess. Usually these concerns are just ignored because they undermine the plot or themes of the story.
In reality, robots are not tropes or story elements to contrast against humans, but tools meant to serve a specific purpose. As a result of science fiction's prominence in pop culture, it's become very common to think of something identified as a 'robot' as something separate from a merely 'autonomous tool,' and thus it's also common to presume that all true robots are general-purpose humanoids. Robots are always built with a use-case in mind, with the caveat that they can do these jobs without constant human supervision. If this job is to merely spread butter and jam on toast, there's no point making a robot more complicated than a gripper with a knife. As most tasks are more complicated, it stands to reason that some will find utility in a more general-purpose design. However, even for the most general-purpose tasks, the humanoid form is not necessary and is often detrimental.
That's not to say there is absolutely no reason to making a robot indistinguishable from humans or even one that's vaguely humanoid: in a world constructed primarily for humans by humans, having a machine that's much like humans can have its uses.
In fiction, however, due to budget limitations, creativity gaps, innocent ignorance (as most people are unaware of the extraordinary requirements and lack of practicality to making such robots due to that knowledge being more esoteric) or the necessity to tell a tale with a specific trope, it's far more common to see creators assuming most robots will be humanoid or outright artificial humans. Even though it would be horribly inefficient to use artificial humans for automated labor in outer space or in a futuristic industrial factory, it's easier to tell a story about them that audiences will care for.
But in some cases, the desire to use Ridiculously Human Robots can betray the story's central point, such as if the story is rooted in robot civil rights narratives where you're supposed to sympathize with the robots being oppressed by bigoted humans in which case, there's a near 100% chance the robots will be indistinguishable from humans save for some small marker to remind audiences they're machines because humans can't easily sympathize with or tell a completely serious story about a sentient toaster demanding equal rights even though the central point of such a narrative is that one's right to life and respect should not be determined by how they were born, if they were 'born' at all, and an intelligent entity that doesn't resemble a human would make that point more effectively.