If I accidentally touch the opposite gender, is it a sin? Like for example, when a woman gives me money back (cashier), or at drive throughs where I might touch her hand while she’s giving me my order.

If it was intentionally then it was sin but in future be cautious.