You have to purchase your tickets before you board any public transport in Rome. Most people will have a pass of one kind or another. From January 2023 contactless payments will be accepted across the ATAC network. These work in the same way as tickets, just using your card or device to tap in and out on your journey.