Depends on who you're talking about, really, what level, what type.
Some people, like mobsters, may be sort of, or literally, born into the business (if not literally, then they know people in the neighbourhood and start doing stuff, even non-criminal low-level, 'working for' stuff as kids, and grow up in the organization. That doesn't have to be the actual mafia; it can be true for drug dealers too. Some kids start running errands or being little lookouts for older siblings or cousins or neighbours in project housing at like 9 or 10 and get more responsibilities as they get older.
Some people learn stuff and network in jail or prison -- this is very common, and where a lot of your lower-level stuff comes from.
People who, say, want to hire someone to off their ex, who aren't criminals themselves, don't end up hiring good assassins, because they don't know people at that level of criminal enterprise, or know anyone who does. They do, however, like, go to a bar, or talk to a guy they know who does construction who once did a little time for stealing a car, who knows a guy from jail who... etc. That's where most of your criminal networking takes place.
Friends who can protect them from the law depends -- most people of the just above type don't really. They might know a beat cop or two who's on the take, who might look the other way if a shipment of TVs is jacked, as long as the cop goes home with a TV, but they're not like, a mafia bigwig or an international jewel thief who has actual lawyers and such at their disposal and may have higher-level contacts. The general population of criminals don't get out of trouble that often; they;re in and out of jail and prison a lot, and that's how they learn and hone their skills and network. Higher-end people tend to be pickier, and get caught less often because they take fewer risks, because they can afford to. Hence it depends on what you're talking about.