As noted, BART is mostly for inter-city travel between towns around the Bay. For travel within SF, you're better off with Muni, which runs the buses, cable cars, street cars, etc, within San Francisco proper.
For a comprehensive web site on all transit within the SF Bay area, check out
http://511.org. It is a clearinghouse of all the various agencies: BART, SF Muni, AC Transit, CalTrain, ferries, etc, etc. It has a trip planner that incorporates them all.
For a map of the Muni system -- buses, street cars, etc within SF proper, check out
https://www.sfmta.com/maps/muni-system-map
To get from Union Square to the wharf area, you have two primary choices:
The touristy thing to do is take the cable car (Powell-Hyde or Powell-Mason). It's a cool thing to do for a tourist. But it's a bit pricey, and it can be difficult to get onto, since it's so popular. There are long lines at the terminii of the cable car lines, and when it passes any of the stops between, it frequently has no room.
The other method is the bus. The 30 Stockton is probably the best route for you between Union Square and the wharf. Or perhaps the 8 Bayshore.
Also, check the SFMTA site for multi-day passes.
HTH,
Bob