Cape Cod is easily reached from Boston via Route 3 and from Providence via I-195. Once you cross Cape Cod Canal, you can follow U.S. 6. Without any traffic, it takes about an hour to 90 minutes to reach the canal from either Boston or Providence. Allow an extra 30 to 60 minutes' travel time in peak periods.
Parking, in general, can be a challenge in summer, especially in congested downtowns and at popular beaches. If you can walk, bike, carpool, or cab it somewhere, do so. But unless you are planning to focus your attention on a single community, you'll probably need a car. Taking a vehicle onto the island ferries is expensive and requires reservations (another option is renting upon arrival).