One obvious way to buy train tickets in Italy is stand in line at the railroad station's biglietteria, or ticket office. Unfortunately, queues in large stations are often horrendous, especially on weekends and during high season. The situation can be so bad that, at the Stazione Termini in Rome, there's a sign near the ticket windows with a list of other ticket vendors (such as newsstands, tobacconists, and travel agencies) in or near the station.
Fortunately, you don't need to stand in line if you just want a point-to-point ticket (either one-way or roundtrip) rather than a complicated routing. Just go to a Trenitalia ticket-vending machine and use the touch-sensitive display to buy your ticket. You can pay with cash, a debit card, or a credit card.