The city centre is compact enough to walk, but the bus terminal, train station, and ferry piers are spread out and not all central. Songthaews (shared pickup trucks) run fixed routes through town for a few baht. Tuk-tuks and motorcycle taxis are available for short hops.
The main ferry pier for the islands is at Don Sak, about 60 km east of town. Most guesthouses and the major tour agencies near the bus terminal sell combined tickets that include transport to Don Sak and a ferry onward to Koh Samui, Koh Phangan, or Koh Tao. This is usually the easiest approach for travellers.
For Koh Samui specifically, there are also direct catamaran services from a pier much closer to the town centre — ask locally, as the options change.