Tropes such as this and Cowboy Cop tend to be more beloved in fiction than in real life for one important yet often overlooked reason: fiction tends to explain things to the audience. Things like "this is the person who did it". If the audience is outright told who committed a crime, then the perception is that any lawyer defending that person is obstructing justice, and any prosecutor going after someone else is miscarrying it. And in most places, someone arrested in the middle of committing a crime gets much the same civil rights as someone arrested after the fact; they're entitled to legal representation, entitled not to say anything until they've consulted with a lawyer, entitled to a fair and impartial trial by a jury of their peers, and so forth. All that would really be different would be that if the case did go to trial, the charges might be slightly different depending on precisely when they were nabbed (attempted murder, say, instead of actual murder) and the prosecution's job would presumably be made much easier by the fact that they had plenty of witnesses, including police officers, who they could call to testify against the defendant, and evidence that could be more easily preserved. It would be a much more open-and-shut case — which is probably why it doesn't appear much in fiction, because there's less drama (less ambiguity about who the culprit is, and said culprit is more likely to cut a deal rather than risk a trial which they'd be more likely to be found guilty at, and so forth).
To say nothing of the fact that in most cases, when criminals are caught in the act of committing a crime, they generally plead guilty (often on the advice of their own attorney) and the trial never takes place at all. Obviously, this doesn't make for good TV, which is why you almost never see it on police procedurals.