Do more than verbally apologize to the cashier.
There is formal process call Restorative Justice. From the website: Restorative justice views crime as more than breaking the law – it also causes harm to people, relationships, and the community. So a just response must address those harms as well as the wrongdoing. If the parties are willing, the best way to do this is to help them meet to discuss those harms and how to about bring resolution. Other approaches are available if they are unable or unwilling to meet. Sometimes those meetings lead to transformational changes in their live.
You probably won’t have access to a group that does that but you can follow the philosophy of the process and do something more substantive than an apology. This will not only help the cashier but you as well in terms of dealing with the guilt and regret.
Insofar as the “why” you did such an act. Usually people do things that they don’t normally do out of wanting to belong and be accepted by the other person or group. Use that as a teaching moment where you went along without thinking, did something that had bad consequences, that you regretted doing it and that you will not do it again.
If there is a next time where someone tries to tempt you into something that goes against your values then you would know and do better yes? That’s the lesson.
Mark