We just did Stonehenge a few weeks ago using the bus. You pay once for the round trip. When you get on they give you a ticket with a bar code or a QR code. You just scan that any time you need the bus during the round trip.
A few words of caution, if you stop at Old Sarum they just drop you sort of randomly on the street without good markings on where to go. It's a fairly steep hike up to Old Sarum. After visiting Old Sarum you can take any bus (the red busses or the green Stonehenge busses) back to town by scanning your ticket but the red busses don't go back to the train station. And we made the mistake of getting on a green bus that looked like the Stonehenge bus back to the train station that came 3 minutes before the scheduled Stonehenge tour bus but it was actually a regular city bus that was just using the Stonehenge busses, so it dropped us in the middle of Salisbury and we had to walk 15-20 minutes back to the train station. So be sure you're getting on the right bus if being picked back up at Old Sarum.