When you share any item with an user by breaking inheritance and giving unique permissions on it, the “Limited Access” permission level is automatically assigned to the user on the shared item's parent folder/library/site. The limited access permission is provided so that the user can easily access the item by browsing to the parent folder/library without having to browse the direct URL of the item.
If the limited access permission was not granted automatically by SharePoint, the user would get an Access Denied error when try to browse the library or parent folder since the user does not have “Open” permission on the folder. Even though the user has permissions to the document, they do not have permission on the containing folder. Hence they would need permission on the parent folder/library/site as well.
There is a feature "Limited-access user permission lockdown mode" which controls the granting of Limited Access permission by SharePoint. When this feature is enabled, permissions for users with “limited access” permissions, such as Anonymous Users, are reduced, preventing access to Application pages including item properties or list views.