Generally, insurance coverage follows the vehicle primarily and driver secondarily. This means if you got in an accident in your friend's vehicle, most likely the insurance of the car owner would be the first insurance company that would have to pay on a claim, and then secondly the insurance of the driver, you, would be involved if the primary coverage is not enough to cover everything.
This being said, under most insurance policies, others can drive your vehicle as long as you give them permission and you should be able to driver other friends or family member's cars as well. The type of coverage the owner has on them would be the primary insurance on the vehicle. Before driving anyone else's car or allowing someone to drive yours, it is always wise to contact your insurance agent to make sure there are no exclusions on your policy that would not cover you or the car for some reason.
Finally, if you are stopped by a law enforcement officer in someone else's car, you should not get in any trouble as long as the person gave you permission to drive the vehicle and you are able to produce the registration and other documentation the officer might request of you.