On one hand, flipping back and forth is a logistical necessity for the author. Steve is only capable of being in two places. He is either in court listening to the lawyers and various testimonies, or he is in jail listening to the horrific stories of the very real monsters in the cells around him. In order to see all aspects of Steve's trial and time in jail, the book has to take readers to those two locations.
More importantly, those two locations function as a way for the author to more deeply develop Steve Harmon's overall character. When Steve is in court, he is being portrayed as a monster. The prosecutor opens the court case up and isn't afraid of calling Steve a monster. All throughout the court proceedings, Steve even writes the word "monster" down over and over again. His own lawyer has to force him to stop. If we were only allowed to see Steve in the court, we might actually believe that he is a monster. He questions it himself, and his lawyer is only doing her job, regardless of what she does or does not know or believe about Steve. There is certainly enough testimony to make readers question whether or not Steve is actually innocent. The jail scenes are what allow readers to really see that Steve is not the monster that the court officials are trying to make him out to be. Steve is genuinely scared of jail and the people there. He is nothing like them, and that gives us confidence that Steve is an overall good kid. He may not be entirely innocent of the crime, but he is nothing like the monsters that King and others are.