In a word: "Science!"
TrueMotion Family uses cutting edge technology that analyzes a bunch of aspects of your driving and behavior to identify whether you are a driver in a car, a passenger in a car, or traveling via some other mode of transit.
On occasion, the app may mis-classify a trip. When this happens, you can tap on the trip, and edit the mode by tapping the transit mode icon in the top right. This information helps the app better classify future trips.