Part of the transaction is the performance of a service role - they’re thanking you for allowing them to help you. But also it might be a habit if they’re used to serving a queue of customers (“Thank you for waiting”) or just a polite verbal cue that the transaction has started or again the habit of saying thank you on being passed something hand to hand (often shortened to “ta”).