If Mary and John own or use the car together, your example (a) is appropriate
to use in a sentence like this:
Mary and John's new car was stolen from their driveway
Conversely, if Mary has one car, and John another, you could use your
example (b) in the sentence
Both Mary's and John's cars are in the shop.
Or, you could say more comfortably, referring to their two separate
Mary's car and John's car are both
in the shop.
In joint or group possession, add the possessive marker only to the
last noun of the unit, as in the following example. The concept of "unit"
is important here:
Hilary Rodham Clinton and Bill Clinton's
daughter Chelsea graduated from Stanford University.
In individual possession, add -'s to each
Hilary Rodham Clinton's and Bill Clinton's
different lives now keep them apart in different cities.