It's not always by default, but sometimes hotels prepare the key cards in advance to save time at check in, and then they might prepare two per room. Hotels default to giving out two key cards as a safety precaution. It ensures that if one card is lost or stolen, the guest still has access to their room.