There's two different courses of discussion here.
First, some states define this in their criminal laws. In many states, a person who joins someone in a crime are held equally responsible for the crime and face the same penalty, even if they did not take part in the actual commission of the crime itself. For example, getaway drivers or a friend tagging along during a robbery would fall under this.
Other states recognize a difference and provide lesser consequences for accomplices.
Accomplices who are held equally responsible under the law can usually get a lesser sentence by presenting evidence to a judge or jury that demonstrate they were only an accomplice and therefore not as much of a danger or deserving of as much punishment as the primary actor.
Beyond what statutes say, there's the issue of how much accomplices actually know regarding what will happen during a crime. There's also the issue of what the accomplice benefits by being around during the crime.
For example, a getaway driver in a fast food restaurant robbery who gets half of the money taken certainly knew a robbery would occur and knew they would benefit just the same as the primary actor.
In a second example, a friend may ask another friend to drop him off real fast at a Taco Bell so he can get a bean burrito and Mountain Dew. The friend driving swings by Taco Bell, and the friend who got the bean burrito also comes out with a wad of cash and tells the driver to drive away fast.
Clearly the friend in the second example is not as liable as the friend in the first example. The problem is criminals lie about involvement, and it's not always easy for the police or district attorney to determine if an accomplice actually knew what was going on.
An accomplice in either event must still be shown to have known that criminal activity would occur with the primary actor. Evidence often needs to be shown that would incriminate the accomplice.
There's also a common practice of prosecutors granting lesser charges or immunity for accomplices who would then be a witness against the primary actor. If a prosecutor believes public safety and justice would be best served by focusing on the primary actor, the decision to allow an accomplice to get away with a reduced penalty or no penalty at all may be worth the conviction of the primary actor.